Python with Windows Form or GUI

1
Hello, I am a beginner in Python 2.7 and am wondering how I apply graphical interface in applications developed with Python, just as html interfaces to php and visual studio is used to make windows form in C #, but python how does this work?

    
asked by anonymous 06.08.2014 / 00:42

1 answer

7

Python works with several graphical user interface toolkits, such as Gtk, Qt, and wx, but the default toolkit is Tkinter.

A basic example you can try:

from Tkinter import *

def Cumprimente():
    hello.set("Olá, você!")

gui = Tk()

gui.title("Py5 - Python + Tkinter")
gui.geometry("400x300")

btn = Button(gui, text="Cumprimente", command=Cumprimente)
btn.pack()

hello = StringVar()
lbl = Label(gui, textvariable=hello)
lbl.pack()

gui.mainloop()

You can save this as an extension file ".py" in Idle and run through it (F5).

    
06.08.2014 / 03:35