#自定义界面设计
mybutton = Button(parent, **configuration options)
也可以这么写
mybutton.configure(**options)
颜色可以用rgb 也可以使用颜色标准名或者预定义颜色表示
可在 C:\Python27\Tools\pynche html40colors.txt 看到
# HTML 4.0 color names
Black #000000
Silver #c0c0c0
Gray #808080
White #ffffff
Maroon #800000
Red #ff0000
Purple #800080
Fuchsia #ff00ff
Green #008000
Lime #00ff00
Olive #808000
Yellow #ffff00
Navy #000080
Blue #0000ff
Teal #008080
Aqua #00ffff
字体 样式设置
widget.configure( font= 'font family, fontsize, optional style modifiers
like bold, italic, underline and overstrike')
例子
widget.configure (font='Times, 8')
widget.configure (font = 'Helvetica 24 bold italic')
大小参数 可以使用px 也可以使用m(millimiters),c(centimeters),i(inches)等
Tkinter的边框一般是2px 可以修改 如下:
button.configure(borderwidth=5)
widget有5种浮雕样式:
flat, raised, sunken,groove, an d ridge.
设置如下
button.configure (relief='raised')

鼠标(悬浮状态)样式也可以变化
button.configure (cursor='cross')

为方便自定义样式 可以将样式写在一个txt文件 作为样式数据
*font: Arial 10
*Label*font: Times 12 bold
*background: AntiqueWhite1
*Text*background: #454545
*Button*foreground:gray55
*Button*relief: raised
*Button*width: 3
加*表示 通用于widget的所有元素
root.option_readfile('optionDB.txt')
option_readfile表示调用哪个数据

案例:
root.title("title of my program")
定义标题
root.geometry('142x280+150+200')
定义尺寸和坐标 widthxheight + xoffset + yoffset

self.root.wm_iconbitmap('mynewicon.ico')
or
self.root.iconbitmap('mynewicon.ico ')
修改默认图标
root.overrideredirect(1)
移除框架

案例:
from Tkinter import *
root = Tk()
#demo of some important root methods
root.geometry('142x280+150+200') #specify root window size and position
root.title("Style Demo") #specifying title of the program
#root.wm_iconbitmap('brush1.ico')#changing the default icon
#root.overrideredirect(1) # remove the root border - uncomment
#this line to see the difference
#root.configure(background='#4D4D4D')#top level styling
# connecting to the external styling optionDB.txt
#root.option_readfile('optionDB.txt')
#widget specific styling
mytext = Text(root, background='#101010', foreground="#D6D6D6",
borderwidth=18, relief='sunken', width=16, height=5 )
mytext.insert(END, "Style is knowing \nwho you are, what \nyou want to say, \nand not giving a \ndamn.")
mytext.grid(row=0, column=0, columnspan=6, padx=5, pady=5)
# all the below widgets derive their styling from optionDB.txt file
Button(root, text='*' ).grid(row=1, column=1)
Button(root, text='^' ).grid(row=1, column=2)
Button(root, text='#' ).grid(row=1, column=3)
Button(root, text='<' ).grid(row=2, column=1)
Button(root, text='OK', cursor='target').grid(row=2, column=2)
Button(root, text='>').grid(row=2, column=3)
Button(root, text='+' ).grid(row=3, column=1)
Button(root, text='v', font='Verdana 8').grid(row=3, column=2)
Button(root, text='-' ).grid(row=3, column=3)
for i in range(0,10,1):
Button(root, text=str(i) ).grid( column=3 if i%3==0 else (1 if i%3==1
else 2), row= 4 if i<=3 else (5 if i<=6 else 6))
#styling with built-in bitmap images
mybitmaps = ['info', 'error', 'hourglass', 'questhead', 'question',
'warning']
for i in mybitmaps:
Button(root, bitmap=i, width=20,height=20).grid(row=
(mybitmaps.index(i)+1), column=4,sticky='nw')
root.mainloop()

python之GUI自定义界面设计 2014-4-10的更多相关文章

  1. Python数据结构与算法设计总结篇

    1.Python数据结构篇 数据结构篇主要是阅读[Problem Solving with Python]( http://interactivepython.org/courselib/static ...

  2. PyQt5多个GUI界面设计

    版权声明:本文为博主原创文章,转载 请注明出处:https://blog.csdn.net/sc2079/article/details/90454379 - 写在前面 本科毕业设计终于告一段落了.特 ...

  3. Python 的元类设计起源自哪里?

    一个元老级的 Python 核心开发者曾建议我们( 点击阅读),应该广泛学习其它编程语言的优秀特性,从而提升 Python 在相关领域的能力.在关于元编程方面,他的建议是学习 Hy 和 Ruby.但是 ...

  4. 2014 年10个最佳的PHP图像操作库

    2014 年10个最佳的PHP图像操作库   Thomas Boutell 以及众多的开发者创造了以GD图形库闻名的一个图形软件库,用于动态的图形计算. GD提供了对于诸如C, Perl, Pytho ...

  5. 《Python 数据库 GUI CGI编程》

    本文地址:http://www.cnblogs.com/aiweixiao/p/8390417.html 原文地址 点击关注微信公众号 wenyuqinghuai 1.写在前边 上一次,我们介绍了Py ...

  6. Python的GUI编程(TK)

    TK在大多数 Unix平台.Windows平台和Macintosh系统都是预装好的,TKinter 模块是 Tk GUI 套件的标准Python接口.可实现Python的GUI编程. Tkinter模 ...

  7. python(9): GUI

    实例1: 对输入的所有数字求和, 最后以. 结束输入 def fun(): list1=[] print('input a number:') while True: num=input() if n ...

  8. Python开发GUI工具介绍,实战:将图片转化为素描画!

    欢迎添加华为云小助手微信(微信号:HWCloud002 或 HWCloud003),输入关键字"加群",加入华为云线上技术讨论群:输入关键字"最新活动",获取华 ...

  9. Python开发GUI实战:图片转换素描画工具!

    奋斗没有终点 好好学习72变,因为将来 没有人能替你阻挡81难 . 生如蝼蚁,当有鸿鹄之志: 命如纸薄,应有不屈之心 . ​ 今天被这句话触动了,所以开篇分享给大家.鸡汤有毒,但有时大家却靠它激励自己 ...

随机推荐

  1. 题解报告:hdu1231最大连续子序列

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231 Problem Description 给定K个整数的序列{ N1, N2, ..., NK } ...

  2. NTP服务简介

    定义:NTP全称为Network Time Protocol,即网络时间协议.是用来使计算机时间同步的一种协议.它可以使计算机对服务器或时钟源做同步,可以提供高精度的时间校正(LAN 上与标准时间小于 ...

  3. 基于Java实现的冒泡排序算法

    冒泡排序是一种简单基础的排序算法,相信在大学课堂里老师已经讲过了,现在我基于Java来实现一遍. 简述 冒泡排序正如其关键词一样,杂乱的气泡经过浮动,最后大的气泡飘到了上面而小的气泡在下面,无序的元素 ...

  4. AJPFX总结java 中类的创建和使用

    //面向对象中类的创建和 调用 ============================================================= 类的使用: 类的使用分为两个动作:创建对象与 ...

  5. JVM线程与Linux内核线程的映射[转]

    Linux从内核2.6开始使用NPTL (Native POSIX Thread Library)支持,但这时线程本质上还轻量级进程. Java里的线程是由JVM来管理的,它如何对应到操作系统的线程是 ...

  6. JavaScript 字符串与数字的相互转换

    js字符串转换成数字 js 字符串转换数字方法主要有三种:转换函数.强制类型转换.利用JS变量弱类型特点进行转换 1. 转换函数:js提供了parseInt()和parseFloat()两个转换函数. ...

  7. QTableWidget表头样式

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7742680.html QTableView { background-color: rgba(255, 255 ...

  8. vue下axios和fetch跨域请求

    1.在config的index.js下面进行常用跨域配置代码:proxyTable: { '/apis': { //使用"/api"来代替"http://xxxx.cn& ...

  9. 在windows上安装Jenkins---tomcat流

    在windows上安装Jenkins有两种方式: (1)jar流 在命令行中运行:java -jar jenkins.war 浏览器访问 localhost:8080,创建初始管理员帐号即可. (2) ...

  10. 51nod 1031 骨牌覆盖

    基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 在2*N的一个长方形方格中,用一个1*2的骨牌排满方格.   问有多少种不同的排列方法.   例如: ...