forked from ubbn/wxPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1444181
Showing
196 changed files
with
9,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import wx | ||
|
||
class App(wx.App): | ||
|
||
def OnInit(self): | ||
frame = wx.Frame(parent=None, title='Bare') | ||
frame.Show() | ||
return True | ||
|
||
app = App() | ||
app.MainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Hello, wxPython! program.""" | ||
|
||
import wx | ||
|
||
class Frame(wx.Frame): | ||
"""Frame class that displays an image.""" | ||
|
||
def __init__(self, image, parent=None, id=-1, | ||
pos=wx.DefaultPosition, title='Hello, wxPython!'): | ||
"""Create a Frame instance and display image.""" | ||
temp = image.ConvertToBitmap() | ||
size = temp.GetWidth(), temp.GetHeight() | ||
wx.Frame.__init__(self, parent, id, title, pos, size) | ||
self.bmp = wx.StaticBitmap(parent=self, bitmap=temp) | ||
self.SetClientSize(size) | ||
|
||
class App(wx.App): | ||
"""Application class.""" | ||
|
||
def OnInit(self): | ||
image = wx.Image('wxPython.jpg', wx.BITMAP_TYPE_JPEG) | ||
self.frame = Frame(image) | ||
self.frame.Show() | ||
self.SetTopWindow(self.frame) | ||
return True | ||
|
||
def main(): | ||
app = App() | ||
app.MainLoop() | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import wx | ||
|
||
class MyApp(wx.App): | ||
|
||
def OnInit(self): | ||
frame = MyFrame("Hello World", (50, 60), (450, 340)) | ||
frame.Show() | ||
self.SetTopWindow(frame) | ||
return True | ||
|
||
class MyFrame(wx.Frame): | ||
|
||
def __init__(self, title, pos, size): | ||
wx.Frame.__init__(self, None, -1, title, pos, size) | ||
menuFile = wx.Menu() | ||
menuFile.Append(1, "&About...") | ||
menuFile.AppendSeparator() | ||
menuFile.Append(2, "E&xit") | ||
menuBar = wx.MenuBar() | ||
menuBar.Append(menuFile, "&File") | ||
self.SetMenuBar(menuBar) | ||
self.CreateStatusBar() | ||
self.SetStatusText("Welcome to wxPython!") | ||
self.Bind(wx.EVT_MENU, self.OnAbout, id=1) | ||
self.Bind(wx.EVT_MENU, self.OnQuit, id=2) | ||
|
||
def OnQuit(self, event): | ||
self.Close() | ||
|
||
def OnAbout(self, event): | ||
wx.MessageBox("This is a wxPython Hello world sample", | ||
"About Hello World", wx.OK | wx.ICON_INFORMATION, self) | ||
|
||
if __name__ == '__main__': | ||
app = MyApp(False) | ||
app.MainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/env python | ||
import wx | ||
|
||
class MyFrame(wx.Frame): | ||
|
||
def __init__(self): | ||
wx.Frame.__init__(self, None, -1, "My Frame", size=(300, 300)) | ||
panel = wx.Panel(self, -1) | ||
panel.Bind(wx.EVT_MOTION, self.OnMove) | ||
wx.StaticText(panel, -1, "Pos:", pos=(10, 12)) | ||
self.posCtrl = wx.TextCtrl(panel, -1, "", pos=(40, 10)) | ||
|
||
def OnMove(self, event): | ||
pos = event.GetPosition() | ||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y)) | ||
|
||
if __name__ == '__main__': | ||
app = wx.PySimpleApp() | ||
frame = MyFrame() | ||
frame.Show(True) | ||
app.MainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Spare.py is a starting point for simple wxPython programs.""" | ||
|
||
import wx | ||
|
||
class Frame(wx.Frame): | ||
pass | ||
|
||
class App(wx.App): | ||
|
||
def OnInit(self): | ||
self.frame = Frame(parent=None, title='Spare') | ||
self.frame.Show() | ||
self.SetTopWindow(self.frame) | ||
return True | ||
|
||
if __name__ == '__main__': | ||
app = App() | ||
app.MainLoop() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
import wx | ||
import images | ||
|
||
class App(wx.App): | ||
|
||
def __init__(self, redirect=True, filename=None): | ||
wx.App.__init__(self, redirect, filename) | ||
|
||
def OnInit(self): | ||
dlg = wx.MessageDialog(None, 'Is this the coolest thing ever!', | ||
'MessageDialog', wx.YES_NO | wx.ICON_QUESTION) | ||
result = dlg.ShowModal() | ||
dlg.Destroy() | ||
|
||
dlg = wx.TextEntryDialog(None, "Who is buried in Grant's tomb?", | ||
'A Question', 'Cary Grant') | ||
if dlg.ShowModal() == wx.ID_OK: | ||
response = dlg.GetValue() | ||
dlg.Destroy() | ||
|
||
dlg = wx.SingleChoiceDialog(None, | ||
'What version of Python are you using?', 'Single Choice', | ||
['1.5.2', '2.0', '2.1.3', '2.2', '2.3.1']) | ||
if dlg.ShowModal() == wx.ID_OK: | ||
response = dlg.GetStringSelection() | ||
dlg.Destroy() | ||
|
||
return True | ||
|
||
|
||
if __name__ == '__main__': | ||
app = App(False, "output") | ||
fred = app.MainLoop() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#---------------------------------------------------------------------- | ||
# This file was generated by encode_bitmaps.py | ||
# | ||
from wx import ImageFromStream, BitmapFromImage | ||
from wx import EmptyIcon | ||
import cStringIO | ||
|
||
def getNewData(): | ||
return \ | ||
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x0f\x08\x06\ | ||
\x00\x00\x00\xedsO/\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\ | ||
\x00YIDATx\x9c\xed\xd31\n@!\x0c\x03\xd0\xa4\xfe\xfb\xdfX\xe3\xf0\x97R\xa5(.\ | ||
\x0ef\x13\xe45\xa2\x92Vp\x92\xcf/\xd4\xaa\xb2\xcd\xb4\xc2\x14\x00\x00in\x90\ | ||
\x84ZUDl\xa9\xa7\xc3c\xcb-\x80\xfc\x87{d8B6=B\xdb\rfy\xc0\r\xc0\xf0\x0e\xfc\ | ||
\x1d\xaf\x84\xa7\xbf\xb1\x03\xe1,\x19&\x93\x9a\xd2\x97\x00\x00\x00\x00IEND\ | ||
\xaeB`\x82' | ||
|
||
def getNewBitmap(): | ||
return BitmapFromImage(getNewImage()) | ||
|
||
def getNewImage(): | ||
stream = cStringIO.StringIO(getNewData()) | ||
return ImageFromStream(stream) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
|
||
import wx | ||
|
||
class InsertFrame(wx.Frame): | ||
|
||
def __init__(self, parent, id): | ||
wx.Frame.__init__(self, parent, id, 'Frame With Button', | ||
size=(300, 100)) | ||
panel = wx.Panel(self) | ||
button = wx.Button(panel, label="Close", pos=(125, 10), | ||
size=(50, 50)) | ||
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) | ||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) | ||
|
||
def OnCloseMe(self, event): | ||
self.Close(True) | ||
|
||
def OnCloseWindow(self, event): | ||
self.Destroy() | ||
|
||
if __name__ == '__main__': | ||
app = wx.PySimpleApp() | ||
frame = InsertFrame(parent=None, id=-1) | ||
frame.Show() | ||
app.MainLoop() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
|
||
import wx | ||
import sys | ||
|
||
class Frame(wx.Frame): | ||
|
||
def __init__(self, parent, id, title): | ||
print "Frame __init__" | ||
wx.Frame.__init__(self, parent, id, title) | ||
|
||
class App(wx.App): | ||
|
||
def __init__(self, redirect=True, filename=None): | ||
print "App __init__" | ||
wx.App.__init__(self, redirect, filename) | ||
|
||
def OnInit(self): | ||
print "OnInit" | ||
self.frame = Frame(parent=None, id=-1, title='Startup Window') | ||
self.frame.Show() | ||
self.SetTopWindow(self.frame) | ||
print >> sys.stderr, "A pretend error message" | ||
print "app name: <", self.GetVendorName(), ">" | ||
return True | ||
|
||
def OnExit(self): | ||
print "OnExit" | ||
|
||
if __name__ == '__main__': | ||
app = App(redirect=True) | ||
print "before MainLoop" | ||
fred = app.MainLoop() | ||
print "after MainLoop", fred | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import wx | ||
import images | ||
|
||
class ToolbarFrame(wx.Frame): | ||
|
||
def __init__(self, parent, id): | ||
wx.Frame.__init__(self, parent, id, 'Toolbars', | ||
size=(300, 200)) | ||
panel = wx.Panel(self) | ||
panel.SetBackgroundColour('White') | ||
statusBar = self.CreateStatusBar() | ||
toolbar = self.CreateToolBar() | ||
toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), | ||
"New", "Long help for 'New'") | ||
toolbar.Realize() | ||
menuBar = wx.MenuBar() | ||
menu1 = wx.Menu() | ||
menuBar.Append(menu1, "&File") | ||
menu2 = wx.Menu() | ||
menu2.Append(wx.NewId(), "&Copy", "Copy in status bar") | ||
menu2.Append(wx.NewId(), "C&ut", "") | ||
menu2.Append(wx.NewId(), "Paste", "") | ||
menu2.AppendSeparator() | ||
menu2.Append(wx.NewId(), "&Options...", "Display Options") | ||
menuBar.Append(menu2, "&Edit") | ||
self.SetMenuBar(menuBar) | ||
|
||
def OnCloseMe(self, event): | ||
self.Close(True) | ||
|
||
def OnCloseWindow(self, event): | ||
self.Destroy() | ||
|
||
if __name__ == '__main__': | ||
app = wx.PySimpleApp() | ||
frame = ToolbarFrame(parent=None, id=-1) | ||
frame.Show() | ||
app.MainLoop() | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import wx | ||
|
||
class TwoButtonEvent(wx.PyCommandEvent): | ||
def __init__(self, evtType, id): | ||
wx.PyCommandEvent.__init__(self, evtType, id) | ||
self.clickCount = 0 | ||
|
||
def GetClickCount(self): | ||
return self.clickCount | ||
|
||
def SetClickCount(self, count): | ||
self.clickCount = count | ||
|
||
myEVT_TWO_BUTTON = wx.NewEventType() | ||
EVT_TWO_BUTTON = wx.PyEventBinder(myEVT_TWO_BUTTON, 1) | ||
|
||
class TwoButtonPanel(wx.Panel): | ||
def __init__(self, parent, id=-1, leftText="Left", | ||
rightText="Right"): | ||
wx.Panel.__init__(self, parent, id) | ||
self.leftButton = wx.Button(self, label=leftText) | ||
self.rightButton = wx.Button(self, label=rightText, | ||
pos=(100,0)) | ||
self.leftClick = False | ||
self.rightClick = False | ||
self.clickCount = 0 | ||
self.leftButton.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick) | ||
self.rightButton.Bind(wx.EVT_LEFT_DOWN, self.OnRightClick) | ||
|
||
def OnLeftClick(self, event): | ||
self.leftClick = True | ||
self.OnClick() | ||
event.Skip() | ||
|
||
def OnRightClick(self, event): | ||
self.rightClick = True | ||
self.OnClick() | ||
event.Skip() | ||
|
||
def OnClick(self): | ||
self.clickCount += 1 | ||
if self.leftClick and self.rightClick: | ||
self.leftClick = False | ||
self.rightClick = False | ||
evt = TwoButtonEvent(myEVT_TWO_BUTTON, self.GetId()) | ||
evt.SetClickCount(self.clickCount) | ||
self.GetEventHandler().ProcessEvent(evt) | ||
|
||
|
||
class CustomEventFrame(wx.Frame): | ||
def __init__(self, parent, id): | ||
wx.Frame.__init__(self, parent, id, 'Click Count: 0', | ||
size=(300, 100)) | ||
panel = TwoButtonPanel(self) | ||
self.Bind(EVT_TWO_BUTTON, self.OnTwoClick, panel) | ||
|
||
def OnTwoClick(self, event): | ||
self.SetTitle("Click Count: %s" % event.GetClickCount()) | ||
|
||
if __name__ == '__main__': | ||
app = wx.PySimpleApp() | ||
frame = CustomEventFrame(parent=None, id=-1) | ||
frame.Show() | ||
app.MainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
|
||
import wx | ||
|
||
class DoubleEventFrame(wx.Frame): | ||
|
||
def __init__(self, parent, id): | ||
wx.Frame.__init__(self, parent, id, 'Frame With Button', | ||
size=(300, 100)) | ||
self.panel = wx.Panel(self, -1) | ||
self.button = wx.Button(self.panel, -1, "Click Me", pos=(100, 15)) | ||
self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.button) | ||
self.button.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) | ||
|
||
def OnButtonClick(self, event): | ||
self.panel.SetBackgroundColour('Green') | ||
self.panel.Refresh() | ||
|
||
def OnMouseDown(self, event): | ||
self.button.SetLabel("Again!") | ||
event.Skip() | ||
|
||
if __name__ == '__main__': | ||
app = wx.PySimpleApp() | ||
frame = DoubleEventFrame(parent=None, id=-1) | ||
frame.Show() | ||
app.MainLoop() | ||
|
Oops, something went wrong.