Barra laterale

Command disabled: revisions
programmazione:python:ttk_hello_world

Hello world in Python tkinter (ttk)

Autore: Fabio Di Matteo
Ultima revisione: 02/01/2019 - 15:59

Un semplice hello world che mostra 2 finestre

#!/usr/bin/python3
# -*- coding: utf-8 -*-
 
import tkinter, sys
from tkinter import ttk 
 
class mainWin():
 
	def __init__(self):
		root = tkinter.Tk()
		root.geometry("800x600+30+30")
		s=tkinter.ttk.Style()
		if sys.platform == 'win32': s.theme_use('vista')
		if sys.platform == 'linux': s.theme_use('clam')
		if sys.platform == 'mac': s.theme_use('acqua')
 
		myLabel = ttk.Label(root, background="red", foreground="white")
		myLabel['text']="Pronto"
		myLabel['font']="arial 50"
		myLabel.pack()
 
		myButton= ttk.Button(root, text="clicca", command=self.onClick)
		myButton.pack()
 
	def onClick(self):
		print("Clicato")
		win1=secondWin()	
 
 
class secondWin():
	def __init__(self):
		root = tkinter.Tk()
		root.geometry("800x600+30+30") 
 
		myLabel = ttk.Label(root)
		myLabel['text']="Seconda finestra"
		myLabel['font']="arial 50"
		myLabel.pack()
 
 
 
win0=mainWin()
tkinter.mainloop()

programmazione/python/ttk_hello_world.txt · Ultima modifica: 02/01/2019 - 16:01 da Fabio Di Matteo