wxPython 2.0b9, first phase (win32)
Added gobs of stuff, see wxPython/README.txt for details git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -76,6 +76,7 @@ class MyApp(wxApp):
|
||||
app = MyApp(0) # Create an instance of the application class
|
||||
app.MainLoop() # Tell it to start processing events
|
||||
|
||||
print 'done!'
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
@@ -19,9 +19,9 @@ from wxPython.wx import *
|
||||
|
||||
|
||||
|
||||
class MyCanvas(wxWindow):
|
||||
class MyCanvas(wxScrolledWindow):
|
||||
def __init__(self, parent):
|
||||
wxWindow.__init__(self, parent, -1, wxPoint(0, 0), wxPyDefaultSize, wxSUNKEN_BORDER)
|
||||
wxScrolledWindow.__init__(self, parent, -1, wxPoint(0, 0), wxPyDefaultSize, wxSUNKEN_BORDER)
|
||||
|
||||
self.SetBackgroundColour(wxNamedColor("WHITE"))
|
||||
self.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnLeftButtonEvent)
|
||||
@@ -30,16 +30,17 @@ class MyCanvas(wxWindow):
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_PENCIL))
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
print 'bmp OK:', bmp.Ok()
|
||||
print 'bmp: (%dx%dx%d)' % (bmp.GetWidth(), bmp.GetHeight(), bmp.GetDepth())
|
||||
self.bmp = bmp
|
||||
|
||||
self.SetScrollbars(20, 20, 50, 50)
|
||||
|
||||
self.lines = []
|
||||
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.PrepareDC(dc)
|
||||
self.DoDrawing(dc)
|
||||
|
||||
|
||||
@@ -133,6 +134,7 @@ class MyApp(wxApp):
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -152,6 +154,17 @@ if __name__ == '__main__':
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.3 1999/04/30 03:29:53 RD
|
||||
# wxPython 2.0b9, first phase (win32)
|
||||
# Added gobs of stuff, see wxPython/README.txt for details
|
||||
#
|
||||
# Revision 1.2.4.1 1999/03/27 23:30:00 RD
|
||||
#
|
||||
# wxPython 2.0b8
|
||||
# Python thread support
|
||||
# various minor additions
|
||||
# various minor fixes
|
||||
#
|
||||
# Revision 1.2 1998/12/15 20:44:34 RD
|
||||
# Changed the import semantics from "from wxPython import *" to "from
|
||||
# wxPython.wx import *" This is for people who are worried about
|
||||
|
@@ -50,7 +50,6 @@ class MyMiniFrame(wxMiniFrame):
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
@@ -147,6 +146,10 @@ if __name__ == '__main__':
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.6 1999/04/30 03:29:53 RD
|
||||
# wxPython 2.0b9, first phase (win32)
|
||||
# Added gobs of stuff, see wxPython/README.txt for details
|
||||
#
|
||||
# Revision 1.5 1999/02/20 09:04:43 RD
|
||||
# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
# window handle. If you can get the window handle into the python code,
|
||||
|
@@ -22,7 +22,7 @@ class TestSimpleControlsDlg(wxDialog):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxDialog.__init__(self, parent, -1, "Test Simple Controls",
|
||||
wxDefaultPosition, wxSize(350, 350))
|
||||
wxDefaultPosition, wxSize(350, 400))
|
||||
|
||||
|
||||
sampleList = ["zero", "one", "two", "three", "four", "five",
|
||||
@@ -250,10 +250,9 @@ class ColoredPanel(wxWindow):
|
||||
|
||||
class TestNotebookWindow(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test wxNotebook',
|
||||
wxDefaultPosition, wxDefaultSize)
|
||||
wxFrame.__init__(self, parent, -1, 'Test wxNotebook')
|
||||
|
||||
nb = wxNotebook(self, -1)
|
||||
nb = wxNotebook(self, -1, wxPoint(0,0), self.GetClientSize())
|
||||
|
||||
win = ColoredPanel(nb, wxBLUE)
|
||||
nb.AddPage(win, "Blue")
|
||||
@@ -295,9 +294,8 @@ class TestNotebookWindow(wxFrame):
|
||||
win = ColoredPanel(nb, wxNamedColour('INDIAN RED'))
|
||||
nb.AddPage(win, "INDIAN RED")
|
||||
|
||||
|
||||
nb.SetSelection(0)
|
||||
self.SetSize(wxSize(350, 300)) # force a redraw so the notebook will draw
|
||||
self.SetSize(wxSize(350, 300))
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
@@ -518,8 +516,8 @@ class TestListCtrlPanel(wxPanel):
|
||||
wxLC_REPORT|wxSUNKEN_BORDER)
|
||||
self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
|
||||
|
||||
self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
|
||||
wxToolTip_Enable(true)
|
||||
#self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
|
||||
#wxToolTip_Enable(true)
|
||||
|
||||
self.list.InsertColumn(0, "Column 0")
|
||||
self.list.InsertColumn(1, "Column 1")
|
||||
@@ -896,7 +894,7 @@ class AppFrame(wxFrame):
|
||||
|
||||
|
||||
def OnTestPageSetupDlg(self, event):
|
||||
data = wxPageSetupData()
|
||||
data = wxPageSetupDialogData()
|
||||
data.SetMarginTopLeft(wxPoint(50,50))
|
||||
data.SetMarginBottomRight(wxPoint(50,50))
|
||||
dlg = wxPageSetupDialog(self, data)
|
||||
@@ -908,7 +906,7 @@ class AppFrame(wxFrame):
|
||||
dlg.Destroy()
|
||||
|
||||
def OnTestPrintDlg(self, event):
|
||||
data = wxPrintData()
|
||||
data = wxPrintDialogData()
|
||||
data.EnablePrintToFile(true)
|
||||
data.EnablePageNumbers(true)
|
||||
data.EnableSelection(true)
|
||||
@@ -1000,7 +998,16 @@ if __name__ == '__main__':
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.16 1999/04/30 03:29:54 RD
|
||||
# wxPython 2.0b9, first phase (win32)
|
||||
# Added gobs of stuff, see wxPython/README.txt for details
|
||||
#
|
||||
# Revision 1.15.2.1 1999/03/16 06:05:50 RD
|
||||
#
|
||||
# wxPython 2.0b7
|
||||
#
|
||||
# Revision 1.15 1999/03/05 07:23:42 RD
|
||||
#
|
||||
# Minor wxPython changes for wxWin 2.0
|
||||
#
|
||||
# Revision 1.14 1999/02/27 04:20:50 RD
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: test4s.py
|
||||
# Purpose: Stub for test4. Speeds startup time by using compiled version
|
||||
# of test4.py.
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
import test4
|
||||
|
||||
test4.main()
|
85
utils/wxPython/tests/test8.py
Normal file
85
utils/wxPython/tests/test8.py
Normal file
@@ -0,0 +1,85 @@
|
||||
# Thread testing example. Harm van der Heijden, March 26 1999.
|
||||
#
|
||||
# Rule One in threading: make sure only one thread interacts with the
|
||||
# user interface. See the wxTextCtrlQueue class for an example of how
|
||||
# to accomplish this
|
||||
|
||||
import thread
|
||||
import time
|
||||
from whrandom import random
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
# Set this to zero to prevent entering the wxApp mainloop
|
||||
# (for testing whether threads work at all in the absense of wxWindows)
|
||||
use_wxpython = 1
|
||||
|
||||
# write a message to stdout every second
|
||||
def DoThread(mesg):
|
||||
while 1:
|
||||
sleeptime = (random() * 3) + 0.5
|
||||
print "Hello from %s (%1.3f)" % (mesg, sleeptime)
|
||||
time.sleep(sleeptime)
|
||||
|
||||
# the same, but write it to a textctrl.
|
||||
def DoTextCtrlThread(text, mesg):
|
||||
while 1:
|
||||
sleeptime = (random() * 3) + 0.5
|
||||
text.WriteText("Hello from %s (%1.3f)\n" % (mesg, sleeptime))
|
||||
time.sleep(sleeptime)
|
||||
|
||||
# A very simple queue for textctrls.
|
||||
# Nice demonstration of the power of OO programming too (at least I think so!)
|
||||
# WriteText puts text in the queue, rather than writing it immediately.
|
||||
# The main (UI) thread must call Flush to force output. (see MyFrame::OnIdle)
|
||||
class wxTextCtrlQueue(wxTextCtrl):
|
||||
def __init__(self, parent, id, value, pos, size, flags):
|
||||
wxTextCtrl.__init__(self,parent, id, value, pos, size, flags)
|
||||
self.queue = []
|
||||
def WriteText(self, value):
|
||||
self.queue.append(value)
|
||||
def Flush(self):
|
||||
queue = self.queue
|
||||
self.queue = []
|
||||
for value in queue:
|
||||
wxTextCtrl.WriteText(self,value)
|
||||
|
||||
# MyFrame and MyApp are very simple classes to test python threads in
|
||||
# wxPython.
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, NULL, -1, "test threads", wxDefaultPosition, wxSize(300,200))
|
||||
self.text = wxTextCtrlQueue(self, -1, "thread output\n", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE)
|
||||
menu = wxMenu()
|
||||
menu.Append(1001, "Start thread")
|
||||
self.cnt = 0;
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Action")
|
||||
self.SetMenuBar(menubar)
|
||||
EVT_MENU(self, 1001, self.StartThread)
|
||||
def StartThread(self, event):
|
||||
self.cnt = self.cnt + 1
|
||||
thread.start_new_thread(DoTextCtrlThread, (self.text, "thread %d" % self.cnt))
|
||||
def OnIdle(self, event):
|
||||
self.text.Flush()
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = MyFrame()
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
|
||||
# Start two threads that print a message every second
|
||||
thread.start_new_thread(DoThread, ("thread A",))
|
||||
thread.start_new_thread(DoThread, ("thread B",))
|
||||
|
||||
# if using wxpython, open a frame. Otherwise, just hang in while 1
|
||||
if use_wxpython:
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
else:
|
||||
while 1:
|
||||
print "main loop"
|
||||
time.sleep(4)
|
||||
print 'done!'
|
Reference in New Issue
Block a user