Python : 3.7.0
OS : Ubuntu 18.04.1 LTS
IDE : PyCharm .2.4
Conda : 4.5.11
typesetting : Markdown
普通布局
code
"""
@Author : 行初心
@Date : 18-10-1
@Blog : /xingchuxin
@Gitee : /zhichengjiu
"""
from tkinter import *
def main():
root = Tk() # 注意Tk的大小写
text_label = Label(root, text='无漏子')
text_label.pack()
new_text_label = Label(root, text='无花果')
new_text_label.pack()
mainloop()
if __name__ == '__main__':
main()
result
指定位置
code
"""
@Author : 行初心
@Date : 18-10-1
@Blog : /xingchuxin
@Gitee : /zhichengjiu
"""
from tkinter import *
def main():
root = Tk() # 注意Tk的大小写
text_label = Label(root, text='橄榄')
text_label.pack(side=LEFT) # 字在左边
new_text_label = Label(root, text='海松子')
new_text_label.pack(side=RIGHT) # 在右边
mainloop()
if __name__ == '__main__':
main()
result
reference
[文档] /3/library/tkinter.html
resource
[文档] /3
[规范] /dev/peps/pep-0008
[规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
[源码] /downloads/source
[ PEP ] /dev/peps
[平台]
[平台]
Python具有开源、跨平台、解释型和交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
GUI可以选择PyQt5、PySide2、wxPython、PyGObject、wxWidgets等进行创作。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。