TK:TCL/TK, Perl/TK, Python/TK(Tkinter)示例

TK:TCL/TK, Perl/TK, Python/TK(Tkinter)示例

1. TCL/TK

#!/usr/bin/wish

#

#tcl/tk test

#

 

button.btnHello -text hello -command {puts stdout "hello,world!"}

button.btnBye -text Bye! -command {exit}

 

pack.btnHello -padx 60 -pady 5; #set the length and width

pack .btnBye -padx 60 -pady 5;

2. Perl/TK

#!usr/bin/perl

 

use strict;

use warnings;

use Tk;

 

my $mainWd=new MainWindow;

$mainWd->Label(-text=>'hello,world')->pack;

$mainWd->Button(-text=>'Quit',-command=>sub{exit})->pack;

MainLoop;







3. python/TK(Tkinter)

import Tkinter 


def resize(ev=None):

    label.config(font='Helvetica-%d bold' % scale.get() )

if __name__=='__main__':

  

    top=Tkinter.Tk()   #主窗口

    top.geometry('600x400')  #设置了主窗口的初始大小600x400

    top.title('Test') #标题

    #图标

    top.iconbitmap('D:\\py.ico')

  

    #设置标签字体的初始大小

    Initfontsize=12

    label=Tkinter.Label(top,text='Hello world!',font='Helvetica-%d bold'%Initfontsize )

    label.pack(fill='x',expand=1)

    #scale创建进度条,设置回调函数

    #进度条的始末位置为字体的范围

   scale=Tkinter.Scale(top,from_=10,to=40,orient='horizontal',command=resize)

    scale.set(Initfontsize)  #设置起始位置

    scale.pack(fill='x',expand=1)

    # quit对应的command应该填top.destroy函数

    quit=Tkinter.Button(top,text='QUIT',command=top.destroy,activeforeground='white',activebackground='red')

    quit.pack()

  

    #进入消息循环

    Tkinter.mainloop()



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值