all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
from Tkinter import Tk, Label, Button
|
||||
|
||||
def update_label():
|
||||
global n
|
||||
n += 1
|
||||
l["text"] = "Number of clicks: %d" % n
|
||||
|
||||
w = Tk()
|
||||
n = 0
|
||||
l = Label(w, text="There have been no clicks yet")
|
||||
l.pack()
|
||||
Button(w, text="click me", command=update_label).pack()
|
||||
w.mainloop()
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
from Tkinter import Button, Frame, Label, Pack
|
||||
|
||||
class ClickCounter(Frame):
|
||||
def click(self):
|
||||
self.count += 1
|
||||
self.label['text'] = 'Number of clicks: %d' % self.count
|
||||
|
||||
def createWidgets(self):
|
||||
self.label = Label(self, text='here have been no clicks yet')
|
||||
self.label.pack()
|
||||
self.button = Button(self, text='click me', command=self.click)
|
||||
self.button.pack()
|
||||
|
||||
def __init__(self, master=None):
|
||||
Frame.__init__(self, master)
|
||||
Pack.config(self)
|
||||
self.createWidgets()
|
||||
self.count = 0
|
||||
|
||||
if __name__=="__main__":
|
||||
ClickCounter().mainloop()
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import sys
|
||||
from qt import *
|
||||
|
||||
def update_label():
|
||||
global i
|
||||
i += 1
|
||||
lbl.setText("Number of clicks: %i" % i)
|
||||
|
||||
i = 0
|
||||
app = QApplication(sys.argv)
|
||||
win = QWidget()
|
||||
win.resize(200, 100)
|
||||
lbl = QLabel("There have been no clicks yet", win)
|
||||
lbl.setGeometry(0, 15, 200, 25)
|
||||
btn = QPushButton("click me", win)
|
||||
btn.setGeometry(50, 50, 100, 25)
|
||||
btn.connect(btn, SIGNAL("clicked()"), update_label)
|
||||
win.show()
|
||||
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
|
||||
app.exec_loop()
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
import wx
|
||||
|
||||
class MyApp(wx.App):
|
||||
def click(self, event):
|
||||
self.count += 1
|
||||
self.label.SetLabel("Count: %d" % self.count)
|
||||
|
||||
def OnInit(self):
|
||||
frame = wx.Frame(None, wx.ID_ANY, "Hello from wxPython")
|
||||
self.count = 0
|
||||
self.button = wx.Button(frame, wx.ID_ANY, "Click me!")
|
||||
self.label = wx.StaticText(frame, wx.ID_ANY, "Count: 0")
|
||||
self.Bind(wx.EVT_BUTTON, self.click, self.button)
|
||||
|
||||
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.sizer.Add(self.button, True, wx.EXPAND)
|
||||
self.sizer.Add(self.label, True, wx.EXPAND)
|
||||
frame.SetSizer(self.sizer)
|
||||
frame.SetAutoLayout(True)
|
||||
self.sizer.Fit(frame)
|
||||
|
||||
frame.Show(True)
|
||||
|
||||
self.SetTopWindow(frame)
|
||||
return True
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue