当前位置: 首页 > news >正文

做免费网站怎么做织梦移动端网站模板下载

做免费网站怎么做,织梦移动端网站模板下载,网站打开慢 可以只换空间不换域名吗,世界500强企业logo第十二章 图形用户界面 GUI就是包含按钮、文本框等控件的窗口 Tkinter是事实上的Python标准GUI工具包 创建GUI示例应用程序 初探 导入tkinter import tkinter as tk也可导入这个模块的所有内容 from tkinter import *要创建GUI#xff0c;可创建一个将充当主窗口的顶级组…第十二章 图形用户界面 GUI就是包含按钮、文本框等控件的窗口 Tkinter是事实上的Python标准GUI工具包 创建GUI示例应用程序 初探 导入tkinter import tkinter as tk也可导入这个模块的所有内容 from tkinter import *要创建GUI可创建一个将充当主窗口的顶级组件控件。 为此可实例化一个Tk对象。 top Tk()调用函数mainloop以进入Tkinter主事件循环而不是直接退出程序。 from tkinter import * top Tk() mainloop()效果图如下 创建按钮可实例化Button类。 需要使用布局管理器也叫几何体管理器来显示按钮的位置(使用管理器pack) 按钮也可以指定一些文本、给按钮添加行为 from tkinter import * button Button() button.pack() button[text] Click me! def clicked():print(I was clicked!)mainloop()效果图如下 可以不分别给属性赋值而使用方法config同时设置多个属性。 button.config(textClick me!,commandclicked) 还可使用控件的构造函数来配置控件。 Button(textclick me too!,commandclicked).pack() 布局 对控件调用方法pack时将把控件放在其父控件主控件中。 from tkinter import * Label(textIm in the first window!).pack() second Toplevel() Label(second,textIm in the second window!).pack()效果图如下 Toplevel类表示除主窗口外的另一个顶级窗口而Label就是文本标签。 一列按钮 from tkinter import * for i in range(10):Button(texti).pack()mainloop()效果图如下 要快速了解可用的选项可执行如下命令 help(Pack.config)Help on function pack_configure in module tkinter:pack_configure(self, cnf{}, **kw)Pack a widget in the parent widget. Use as options:afterwidget - pack it after you have packed widgetanchorNSEW (or subset) - position widget according togiven directionbeforewidget - pack it before you will pack widgetexpandbool - expand widget if parent size growsfillNONE or X or Y or BOTH - fill widget if widget growsinmaster - use master to contain this widgetin_master - see in option descriptionipadxamount - add internal padding in x directionipadyamount - add internal padding in y directionpadxamount - add padding in x directionpadyamount - add padding in y directionsideTOP or BOTTOM or LEFT or RIGHT - where to add this widget.还有其他的布局管理器具体地说是grid和place help(Grid.configure)Help on function grid_configure in module tkinter:grid_configure(self, cnf{}, **kw)Position a widget in the parent widget in a grid. Use as options:columnnumber - use cell identified with given column (starting with 0)columnspannumber - this widget will span several columnsinmaster - use master to contain this widgetin_master - see in option descriptionipadxamount - add internal padding in x directionipadyamount - add internal padding in y directionpadxamount - add padding in x directionpadyamount - add padding in y directionrownumber - use cell identified with given row (starting with 0)rowspannumber - this widget will span several rowsstickyNSEW - if cell is larger on which sides will thiswidget stick to the cell boundaryhelp(Place.config)Help on function place_configure in module tkinter:place_configure(self, cnf{}, **kw)Place a widget in the parent widget. Use as options:inmaster - master relative to which the widget is placedin_master - see in option descriptionxamount - locate anchor of this widget at position x of masteryamount - locate anchor of this widget at position y of masterrelxamount - locate anchor of this widget between 0.0 and 1.0relative to width of master (1.0 is right edge)relyamount - locate anchor of this widget between 0.0 and 1.0relative to height of master (1.0 is bottom edge)anchorNSEW (or subset) - position anchor according to given directionwidthamount - width of this widget in pixelheightamount - height of this widget in pixelrelwidthamount - width of this widget between 0.0 and 1.0relative to width of master (1.0 is the same widthas the master)relheightamount - height of this widget between 0.0 and 1.0relative to height of master (1.0 is the sameheight as the master)bordermodeinside or outside - whether to take border width ofmaster widget into account事件处理 通过设置属性command给按钮指定动作action这是一种特殊的事件处理。 Tkinter还提供了更通用的事件处理机制方法bind。要让控件对特定的事件进行处理可对其调用方法bind并指定事件的名称和要使用的函数。 点哪儿显示所点击的坐标位置鼠标单击事件提供x和y坐标 其中是使用鼠标左按钮按钮1单击的事件名称。 将这种事件关联到函数callback。 这样每当用户在窗口top中单击时都将调用这个函数。向函数callback传递一个event对象这个对象包含的属性随事件类型而异。 from tkinter import * top Tk() def callback(event):print(event.x,event.y)top.bind(Button-1,callback)#结果为2435082162376callback mainloop()效果图如下 当然也可以查询帮助 help(Tk.bind)Help on function bind in module tkinter:bind(self, sequenceNone, funcNone, addNone)Bind to this widget at event SEQUENCE a call to function FUNC.SEQUENCE is a string of concatenated eventpatterns. An event pattern is of the formMODIFIER-MODIFIER-TYPE-DETAIL where MODIFIER is oneof Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4,Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3,B3, Alt, Button4, B4, Double, Button5, B5 Triple,Mod1, M1. TYPE is one of Activate, Enter, Map,ButtonPress, Button, Expose, Motion, ButtonReleaseFocusIn, MouseWheel, Circulate, FocusOut, Property,Colormap, Gravity Reparent, Configure, KeyPress, Key,Unmap, Deactivate, KeyRelease Visibility, Destroy,Leave and DETAIL is the button number for ButtonPress,ButtonRelease and DETAIL is the Keysym for KeyPress andKeyRelease. Examples areControl-Button-1 for pressing Control and mouse button 1 orAlt-A for pressing A and the Alt key (KeyPress can be omitted).An event pattern can also be a virtual event of the formAString where AString can be arbitrary. Thisevent can be generated by event_generate.If events are concatenated they must appear shortlyafter each other.FUNC will be called if the event sequence occurs with aninstance of Event as argument. If the return value of FUNC isbreak no further bound function is invoked.An additional boolean parameter ADD specifies whether FUNC willbe called additionally to the other bound function or whetherit will replace the previous function.Bind will return an identifier to allow deletion of the bound function withunbind without memory leak.If FUNC or SEQUENCE is omitted the bound function or listof bound events are returned.最终的程序 简单的GUI文本编辑器 1需要输入所要编辑的文本地址 2点击Open即可打开该文本文件 3在下方编辑栏中可随意编辑 4点击Save即可保存 from tkinter import * from tkinter.scrolledtext import ScrolledText def load():with open(filename.get()) as file:contents.delete(1.0, END)contents.insert(INSERT, file.read())def save():with open(filename.get(), w) as file:file.write(contents.get(1.0, END))top Tk() top.title(Simple Editor)contents ScrolledText() contents.pack(sideBOTTOM, expandTrue, fillBOTH)filename Entry() filename.pack(sideLEFT, expandTrue, fillX)Button(textOpen, commandload).pack(sideLEFT) Button(textSave, commandsave).pack(sideLEFT)mainloop()效果图如下 小结 概念描述图形用户界面GUIGUI有助于让应用程序对用户更友好。并非所有的程序都需要GUI但只要程序需要与用户交互GUI就可能很有帮助。TkinterTkinter是一个跨平台的Python GUI工具包成熟而且使用广泛。布局通过指定组件的几何属性很容易对其进行定位但要确保它们在父窗口的大小发生变化时做出正确的反应就必须使用布局管理器。事件处理GUI工具包中用户触发事件执行的操作。要发挥作用程序可能需要响应某些事件否则用户将无法与之交互。在Tkinter中要给组件添加事件处理程序可使用方法bind。
http://www.yutouwan.com/news/327919/

相关文章:

  • 中文网站的seo怎么做建站开发
  • 青岛中英网站建设教育培训网站排名
  • 竞价网站转化率为多少dede网站后台模板
  • 外贸网站如何优化怎么新建自己的网站
  • 网站超级链接网站快速排名优化方法
  • 贵州省住房和城乡建设部官方网站免费ai写作网站
  • 做百度网站多少钱如何做外贸网站的推广
  • 青岛建设集团招聘信息网站网站建设优化的经营范围
  • 初中信息技术 网站制作免费wap自助建站网站
  • 网站建设 图标wordpress安装插件返回空白
  • 建设自动弹出qq对话框的网站全市网站建设情况摸底调查
  • 辽宁省建设工程造价管理协会网站邱县seo整站排名
  • 网站建设的可行性报告企查猫
  • 网站备案名称查询服务平台型网站
  • 爱站网长尾关键词挖掘工具的作用深圳软件定制公司
  • 秋实网站建设温州网站建设免费咨询
  • 南京建设网站首页淘宝网站是怎么做的
  • 文明网i中国精神文明建设门户网站如何在手机上学编程
  • 做网站 学php哪一部分个人网站设计论文ppt
  • 珍佰农 商城网站建设网站的域名做邮箱
  • 百度收录比较好的网站可以发外链的网站或平台有哪些
  • 韩国的小游戏网站江西医疗网站备案前置审批
  • 企业网站营销推广方案多少钱
  • ps做网站首页怎么运用起来mixkit免费高清视频素材
  • 泰州网站建设案例杭州公司建站模板
  • 电子商务是建网站网站名和域名能一样吗
  • 生产备案号怎么查询网站化学药品购买网站
  • 400网站建设办公视频8首页制作代码
  • 海口网站建设维护策划方案
  • 网站制作思路wordpress安全登录插件下载失败