SlideShare une entreprise Scribd logo
1  sur  24
Podstawy tworzenia
GUI w tkinter
Mateusz Dobrychłop
2016, Python 3
import tkinter
top = tkinter.Tk()
top.mainloop()
import tkinter
top = tkinter.Tk()
top.wm_title('Hello...')
label1 = tkinter.Label(top, text='...world!')
label1.pack()
top.mainloop()
import tkinter
top = tkinter.Tk()
top.wm_title('Hello...')
top.resizable(width='false', height='false')
top.minsize(width=200, height=50)
top.maxsize(width=200, height=50)
label1 = tkinter.Label(top, text='...world!')
label1.pack()
top.mainloop()
import tkinter
top = tkinter.Tk()
top.wm_title('Hello...')
top.resizable(width='false', height='false')
top.minsize(width=200, height=50)
top.maxsize(width=200, height=50)
label1 = tkinter.Label(top, text='...world!')
label1.pack()
b_close = tkinter.Button(top, text='Zamknij', command=top.destroy)
b_close.pack()
top.mainloop()
import tkinter
top = tkinter.Tk()
top.wm_title('Hello...')
top.resizable(width='false', height='false')
top.minsize(width=200, height=50)
top.maxsize(width=200, height=50)
label1 = tkinter.Label(top, text='...world!')
label1.pack()
b_close = tkinter.Button(top, text='Zamknij', command=top.destroy)
b_close.pack(fill='x')
top.mainloop()
import tkinter
top = tkinter.Tk()
top.wm_title('Hello...')
top.resizable(width='false', height='false')
top.minsize(width=200, height=50)
top.maxsize(width=200, height=50)
label1 = tkinter.Label(top, text='...world!')
label1.pack()
b_close = tkinter.Button(top, text='Zamknij', command=top.destroy)
b_close.pack(fill='x')
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame1.pack(fill='x')
frame2.pack(fill='x')
label1 = tkinter.Label(frame1, text='...world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack(fill='x')
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame1.pack(fill='y',side='left')
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame2.pack(fill='y',side='left')
label1 = tkinter.Label(frame1, text='...world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack()
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame1.pack(fill='y',side='left')
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame2.pack(fill='y',side='left')
frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame3.pack(fill='y',side='left')
label1 = tkinter.Label(frame1, text='...world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack()
b_color = tkinter.Button(frame3, text='Kolor')
b_color.pack()
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame1.grid(row=0, column=0)
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame2.grid(row=0, column=1)
frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame3.grid(row=1,column=0)
label1 = tkinter.Label(frame1, text='...world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack()
b_color = tkinter.Button(frame3, text='Kolor')
b_color.pack()
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame1.grid(row=0, column=0,sticky='ns')
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame2.grid(row=0, column=1,sticky='ns')
frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge')
frame3.grid(row=1,column=0,sticky='ew')
label1 = tkinter.Label(frame1, text='...world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack()
b_color = tkinter.Button(frame3, text='Kolor')
b_color.pack()
top.mainloop()
frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4)
frame1.grid(row=0, column=0,sticky='ns')
frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4)
frame2.grid(row=0, column=1,sticky='ns')
frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4)
frame3.grid(row=1,column=0,sticky='ew', columnspan=2)
label1 = tkinter.Label(frame1, text='Hello world!')
label1.pack()
b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy)
b_close.pack()
b_color = tkinter.Button(frame3, text='Kolor')
b_color.pack(fill='x')
top.mainloop()
def color_label():
color = tkinter.colorchooser.askcolor(parent=top)
print(color)
label1.configure(bg=color[1])
b_color = tkinter.Button(frame3, text='Kolor', command=color_label)
b_color.pack(fill='x')
((0,255,255), '00ffff')
def color_label(lab):
color = tkinter.colorchooser.askcolor(parent=top)
print(color)
lab.configure(bg=color[1])
b_color = tkinter.Button(frame3, text='Kolor', command=lambda: color_label(label1))
b_color.pack(fill='x')
import tkinter
top = tkinter.Tk()
entry1 = tkinter.Entry(top, width=50)
entry1.pack(side='left')
button_print = tkinter.Button(top, text='Print text')
button_print.pack(side='left')
top.mainloop()
import tkinter
top = tkinter.Tk()
def print_text(ent):
print(ent.get())
entry1 = tkinter.Entry(top, width=50)
entry1.pack(side='left')
button_print = tkinter.Button(top, text='Print text', command=lambda: print_text(entry1))
button_print.pack(side='left')
top.mainloop()
import tkinter
top = tkinter.Tk()
def print_text(ent):
tkinter.messagebox.showinfo('Informacja',ent.get())
entry1 = tkinter.Entry(top, width=50)
entry1.pack(side='left')
button_print = tkinter.Button(top, text='Print text', command=lambda: print_text(entry1))
button_print.pack(side='left')
top.mainloop()
tkMessageBox
• showinfo
• showwarning
• showerror
• askquestion
• askokcancel
• askyesno
• askretrycancel
import tkinter
top = tkinter.Tk()
def print_file():
f = tkinter.filedialog.askopenfilename(
parent=top, initialdir='/',
title='Choose file',
filetypes=[('text files','.txt')]
)
fc = open(f,'r')
print(fc.read())
b1 = tkinter.Button(top, text='Print file content', command=print_file)
b1.pack(anchor='w')
top.mainloop()
import tkinter
top = tkinter.Tk()
colors = [('Red', 'red'),
('Green', 'green'),
('Blue', 'blue'),
('White', 'white')]
v = tkinter.StringVar()
v.set('red')
for text, color in colors:
b = tkinter.Radiobutton(top, text=text, variable=v, value=color)
b.pack(anchor='w')
top.mainloop()
ĆWICZENIE
import tkinter
top = tkinter.Tk()
colors = [('Red', 'red'),
('Green', 'green'),
('Blue', 'blue'),
('White', 'white')]
v = tkinter.StringVar()
v.set('red')
for text, color in colors:
b = tkinter.Radiobutton(top, text=text, variable=v, value=color)
b.pack(anchor='w')
def color_me():
b1.configure(bg=v.get())
b1 = tkinter.Button(top, text='COLOR ME', command=color_me)
b1.pack(anchor='w',fill='x')
top.mainloop()
Przydatne linki
• wiki.python.org/moin/TkInter
• tkdocs.com/tutorial
• tkinter.unpythonic.net/wiki
• pmw.sourceforge.net
• effbot.org/tkinterbook (2.7)
• thinkingtkinter.sourceforge.net (2.7)

Contenu connexe

Tendances

Tendances (20)

Corona sdk
Corona sdkCorona sdk
Corona sdk
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
 
Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2
 
Pemrograman Terstruktur 3
Pemrograman Terstruktur 3Pemrograman Terstruktur 3
Pemrograman Terstruktur 3
 
Ext JS (Greek)
Ext JS (Greek)Ext JS (Greek)
Ext JS (Greek)
 
tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会
 
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180
 
The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202
 
10b. Graph Databases Lab
10b. Graph Databases Lab10b. Graph Databases Lab
10b. Graph Databases Lab
 
ES2015 - Stepan Parunashvili
ES2015 - Stepan ParunashviliES2015 - Stepan Parunashvili
ES2015 - Stepan Parunashvili
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185
 
The Ring programming language version 1.5.2 book - Part 66 of 181
The Ring programming language version 1.5.2 book - Part 66 of 181The Ring programming language version 1.5.2 book - Part 66 of 181
The Ring programming language version 1.5.2 book - Part 66 of 181
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88
 
Basics
BasicsBasics
Basics
 
PureScript & Pux
PureScript & PuxPureScript & Pux
PureScript & Pux
 

En vedette

Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI Programming
Ranel Padon
 
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for PythonwxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
Umar Yusuf
 
OSCON 2008: Porting to Python 3.0
OSCON 2008: Porting to Python 3.0OSCON 2008: Porting to Python 3.0
OSCON 2008: Porting to Python 3.0
guest4d09
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
YLTO
 
Python twitterとtkinterのことはじめ
Python twitterとtkinterのことはじめPython twitterとtkinterのことはじめ
Python twitterとtkinterのことはじめ
Yukitaka Uchikoshi
 

En vedette (20)

Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI Programming
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for PythonwxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
 
Python programming lab2
Python programming lab2Python programming lab2
Python programming lab2
 
Introduction to Graphics
Introduction to GraphicsIntroduction to Graphics
Introduction to Graphics
 
OSCON 2008: Porting to Python 3.0
OSCON 2008: Porting to Python 3.0OSCON 2008: Porting to Python 3.0
OSCON 2008: Porting to Python 3.0
 
Python 3000
Python 3000Python 3000
Python 3000
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
Python programming lab1
Python programming lab1Python programming lab1
Python programming lab1
 
Securing Apache Web Servers
Securing Apache Web ServersSecuring Apache Web Servers
Securing Apache Web Servers
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Python and you
Python and youPython and you
Python and you
 
Apache Web Server Setup 2
Apache Web Server Setup 2Apache Web Server Setup 2
Apache Web Server Setup 2
 
Python twitterとtkinterのことはじめ
Python twitterとtkinterのことはじめPython twitterとtkinterのことはじめ
Python twitterとtkinterのことはじめ
 
10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-python10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-python
 
An introduction-to-tkinter
An introduction-to-tkinterAn introduction-to-tkinter
An introduction-to-tkinter
 
Tkinter Does Not Suck
Tkinter Does Not SuckTkinter Does Not Suck
Tkinter Does Not Suck
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
Chapter 11 Presentation
Chapter 11 PresentationChapter 11 Presentation
Chapter 11 Presentation
 

Similaire à PyTrening 2.0 # 15 Okienka GUI

PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
Yashpatel821746
 

Similaire à PyTrening 2.0 # 15 Okienka GUI (20)

Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
 
Tkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdfTkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdf
 
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAVNOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON 2ND PART BY ROHIT MALAV
 
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD  MAKING IN PAYTHON BY ROHIT MALAVNOTEPAD  MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
tkinter final ppt.ppt
tkinter final ppt.ppttkinter final ppt.ppt
tkinter final ppt.ppt
 
The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88
 
AI02_Python (cont.).pptx
AI02_Python (cont.).pptxAI02_Python (cont.).pptx
AI02_Python (cont.).pptx
 
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
 
Google Go For Ruby Hackers
Google Go For Ruby HackersGoogle Go For Ruby Hackers
Google Go For Ruby Hackers
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust language
 
Assignment 2 lab 3 python gpa calculator
Assignment 2 lab 3  python gpa calculatorAssignment 2 lab 3  python gpa calculator
Assignment 2 lab 3 python gpa calculator
 

Dernier

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 

PyTrening 2.0 # 15 Okienka GUI

  • 1. Podstawy tworzenia GUI w tkinter Mateusz Dobrychłop 2016, Python 3
  • 2. import tkinter top = tkinter.Tk() top.mainloop()
  • 3. import tkinter top = tkinter.Tk() top.wm_title('Hello...') label1 = tkinter.Label(top, text='...world!') label1.pack() top.mainloop()
  • 4. import tkinter top = tkinter.Tk() top.wm_title('Hello...') top.resizable(width='false', height='false') top.minsize(width=200, height=50) top.maxsize(width=200, height=50) label1 = tkinter.Label(top, text='...world!') label1.pack() top.mainloop()
  • 5. import tkinter top = tkinter.Tk() top.wm_title('Hello...') top.resizable(width='false', height='false') top.minsize(width=200, height=50) top.maxsize(width=200, height=50) label1 = tkinter.Label(top, text='...world!') label1.pack() b_close = tkinter.Button(top, text='Zamknij', command=top.destroy) b_close.pack() top.mainloop()
  • 6. import tkinter top = tkinter.Tk() top.wm_title('Hello...') top.resizable(width='false', height='false') top.minsize(width=200, height=50) top.maxsize(width=200, height=50) label1 = tkinter.Label(top, text='...world!') label1.pack() b_close = tkinter.Button(top, text='Zamknij', command=top.destroy) b_close.pack(fill='x') top.mainloop()
  • 7. import tkinter top = tkinter.Tk() top.wm_title('Hello...') top.resizable(width='false', height='false') top.minsize(width=200, height=50) top.maxsize(width=200, height=50) label1 = tkinter.Label(top, text='...world!') label1.pack() b_close = tkinter.Button(top, text='Zamknij', command=top.destroy) b_close.pack(fill='x') top.mainloop()
  • 8. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame1.pack(fill='x') frame2.pack(fill='x') label1 = tkinter.Label(frame1, text='...world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack(fill='x') top.mainloop()
  • 9. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame1.pack(fill='y',side='left') frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame2.pack(fill='y',side='left') label1 = tkinter.Label(frame1, text='...world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack() top.mainloop()
  • 10. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame1.pack(fill='y',side='left') frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame2.pack(fill='y',side='left') frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame3.pack(fill='y',side='left') label1 = tkinter.Label(frame1, text='...world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack() b_color = tkinter.Button(frame3, text='Kolor') b_color.pack() top.mainloop()
  • 11. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame1.grid(row=0, column=0) frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame2.grid(row=0, column=1) frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame3.grid(row=1,column=0) label1 = tkinter.Label(frame1, text='...world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack() b_color = tkinter.Button(frame3, text='Kolor') b_color.pack() top.mainloop()
  • 12. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame1.grid(row=0, column=0,sticky='ns') frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame2.grid(row=0, column=1,sticky='ns') frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge') frame3.grid(row=1,column=0,sticky='ew') label1 = tkinter.Label(frame1, text='...world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack() b_color = tkinter.Button(frame3, text='Kolor') b_color.pack() top.mainloop()
  • 13. frame1 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4) frame1.grid(row=0, column=0,sticky='ns') frame2 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4) frame2.grid(row=0, column=1,sticky='ns') frame3 = tkinter.Frame(top, borderwidth=2, relief='ridge', pady=4, padx=4) frame3.grid(row=1,column=0,sticky='ew', columnspan=2) label1 = tkinter.Label(frame1, text='Hello world!') label1.pack() b_close = tkinter.Button(frame2, text='Zamknij', command=top.destroy) b_close.pack() b_color = tkinter.Button(frame3, text='Kolor') b_color.pack(fill='x') top.mainloop()
  • 14. def color_label(): color = tkinter.colorchooser.askcolor(parent=top) print(color) label1.configure(bg=color[1]) b_color = tkinter.Button(frame3, text='Kolor', command=color_label) b_color.pack(fill='x') ((0,255,255), '00ffff')
  • 15. def color_label(lab): color = tkinter.colorchooser.askcolor(parent=top) print(color) lab.configure(bg=color[1]) b_color = tkinter.Button(frame3, text='Kolor', command=lambda: color_label(label1)) b_color.pack(fill='x')
  • 16. import tkinter top = tkinter.Tk() entry1 = tkinter.Entry(top, width=50) entry1.pack(side='left') button_print = tkinter.Button(top, text='Print text') button_print.pack(side='left') top.mainloop()
  • 17. import tkinter top = tkinter.Tk() def print_text(ent): print(ent.get()) entry1 = tkinter.Entry(top, width=50) entry1.pack(side='left') button_print = tkinter.Button(top, text='Print text', command=lambda: print_text(entry1)) button_print.pack(side='left') top.mainloop()
  • 18. import tkinter top = tkinter.Tk() def print_text(ent): tkinter.messagebox.showinfo('Informacja',ent.get()) entry1 = tkinter.Entry(top, width=50) entry1.pack(side='left') button_print = tkinter.Button(top, text='Print text', command=lambda: print_text(entry1)) button_print.pack(side='left') top.mainloop()
  • 19. tkMessageBox • showinfo • showwarning • showerror • askquestion • askokcancel • askyesno • askretrycancel
  • 20. import tkinter top = tkinter.Tk() def print_file(): f = tkinter.filedialog.askopenfilename( parent=top, initialdir='/', title='Choose file', filetypes=[('text files','.txt')] ) fc = open(f,'r') print(fc.read()) b1 = tkinter.Button(top, text='Print file content', command=print_file) b1.pack(anchor='w') top.mainloop()
  • 21. import tkinter top = tkinter.Tk() colors = [('Red', 'red'), ('Green', 'green'), ('Blue', 'blue'), ('White', 'white')] v = tkinter.StringVar() v.set('red') for text, color in colors: b = tkinter.Radiobutton(top, text=text, variable=v, value=color) b.pack(anchor='w') top.mainloop()
  • 23. import tkinter top = tkinter.Tk() colors = [('Red', 'red'), ('Green', 'green'), ('Blue', 'blue'), ('White', 'white')] v = tkinter.StringVar() v.set('red') for text, color in colors: b = tkinter.Radiobutton(top, text=text, variable=v, value=color) b.pack(anchor='w') def color_me(): b1.configure(bg=v.get()) b1 = tkinter.Button(top, text='COLOR ME', command=color_me) b1.pack(anchor='w',fill='x') top.mainloop()
  • 24. Przydatne linki • wiki.python.org/moin/TkInter • tkdocs.com/tutorial • tkinter.unpythonic.net/wiki • pmw.sourceforge.net • effbot.org/tkinterbook (2.7) • thinkingtkinter.sourceforge.net (2.7)