python实训项目-求一份Python的实验报告+源代码,项目内容不限

匿名用户

1级

2015-06-30 回答

#!/usr/bin/env python

# Filename: appui.py

"""

.. moduleauthor:: ....

.. test module of Tkinter

"""

from Tkinter import *

import tkMessageBox

root = Tk()

root.geometry('850x40+80+80') #设置窗体高宽与窗体相对屏幕左上角位置

class Appui(Frame):

"""

docsting for Appui

"""

def __init__(self, parent=None):

"""

Initialize the Appui Class

"""

Frame.__init__(self, width=850, height=60, bg='gray40')

self.propagate(False)

self.pack()

self.input = StringVar()

self.master.title('Test Widgets')

self.master.iconname('Tk-42')

self.buildFrame() # Build the widgets

def buildFrame(self):

"""

make the frame and add widgets into the frame

"""

self.LabelF=Frame(self,width=850, height=60, bg='gray80')

self.LabelF.propagate(False)

self.LabelF.pack(side=TOP)

Label(self.LabelF, fg='steelblue1', bg='gray80', text= "Text field description: ").pack(side=LEFT)

#设置输入的widgets

self.e0 = Entry(self.LabelF, width=80, textvariable=self.input)

self.e0.pack(side=LEFT)

Button(self.LabelF, text='Get', borderwidth=5, command=self.callback).pack(side=RIGHT,padx=10)

def callback(self):

"""

callback of get path Button

"""

try:

#self.e0.delete(0,END)

Value=self.input.get()

if Value is not None:

print "Get String from Entry" + Value

else:

self.e0.delete(0,END)

except (RuntimeError, TypeError, NameError, ValueError, IOError) as e:

tkMessageBox.showerror("Error function callback()", '%s' % e)

def exit(self):

"""

exit of process

"""

exit(0)

def main():

"""

Main function

"""

Appui().mainloop()

if __name__ == '__main__':

main()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值