Tweaking some of the new wxPython stuff for wxGTK
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
26bf1ce0bc
commit
e0473f5f5a
@ -44,7 +44,7 @@ _treeList = [
|
|||||||
'wxTimer', 'wxValidator', 'wxGLCanvas', 'DialogUnits',
|
'wxTimer', 'wxValidator', 'wxGLCanvas', 'DialogUnits',
|
||||||
'wxImage', 'PrintFramework', 'wxOGL', 'PythonEvents']),
|
'wxImage', 'PrintFramework', 'wxOGL', 'PythonEvents']),
|
||||||
|
|
||||||
('wxPython Library', ['OldSizers', 'Layoutf', 'wxScrolledMessageDialog',
|
('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',
|
||||||
'wxMultipleChoiceDialog', 'wxPlotCanvas', 'wxFloatBar',
|
'wxMultipleChoiceDialog', 'wxPlotCanvas', 'wxFloatBar',
|
||||||
'PyShell', 'wxCalendar']),
|
'PyShell', 'wxCalendar']),
|
||||||
|
|
||||||
@ -161,6 +161,7 @@ class wxPythonDemo(wxFrame):
|
|||||||
(w, self.charHeight) = self.log.GetTextExtent('X')
|
(w, self.charHeight) = self.log.GetTextExtent('X')
|
||||||
self.WriteText('wxPython Demo Log:\n')
|
self.WriteText('wxPython Demo Log:\n')
|
||||||
|
|
||||||
|
self.Show(true)
|
||||||
|
|
||||||
# add the windows to the splitter and split it.
|
# add the windows to the splitter and split it.
|
||||||
if _useSplitter:
|
if _useSplitter:
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
from wxPython.wx import *
|
from wxPython.wx import *
|
||||||
from wxPython.lib.calendar import Calendar, Month, using_mxDateTime
|
from wxPython.lib.calendar import wxCalendar, Month
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
dir_path = os.getcwd()
|
dir_path = os.getcwd()
|
||||||
@ -49,12 +50,7 @@ class TestPanel(wxPanel):
|
|||||||
|
|
||||||
self.log = log
|
self.log = log
|
||||||
|
|
||||||
if using_mxDateTime is true:
|
self.calend = wxCalendar(self, -1, wxPoint(100, 50), wxSize(200, 180))
|
||||||
self.log.WriteText('Using mxDateTime module\n')
|
|
||||||
else:
|
|
||||||
self.log.WriteText('Using Built in CDate module\n')
|
|
||||||
|
|
||||||
self.calend = Calendar(self, -1, wxPoint(100, 50), wxSize(200, 180))
|
|
||||||
|
|
||||||
start_month = 11
|
start_month = 11
|
||||||
start_year = 1999
|
start_year = 1999
|
||||||
@ -104,16 +100,16 @@ class TestPanel(wxPanel):
|
|||||||
|
|
||||||
wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50)).SetBackgroundColour(wxNamedColour('Red'))
|
wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50)).SetBackgroundColour(wxNamedColour('Red'))
|
||||||
|
|
||||||
bmp = wxBitmap('CalBmp/Calend.bmp', wxBITMAP_TYPE_BMP)
|
bmp = wxBitmap('Calbmp/Calend.bmp', wxBITMAP_TYPE_BMP)
|
||||||
self.but = wxBitmapButton(self, 60, bmp, wxPoint(380, 80), wxSize(30, 30))
|
self.but = wxBitmapButton(self, 60, bmp, wxPoint(380, 80))#, wxSize(30, 30))
|
||||||
EVT_BUTTON(self, 60, self.TestDlg)
|
EVT_BUTTON(self, 60, self.TestDlg)
|
||||||
|
|
||||||
# button for calendar window test
|
# button for calendar window test
|
||||||
|
|
||||||
wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150)).SetBackgroundColour(wxNamedColour('Blue'))
|
wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150)).SetBackgroundColour(wxNamedColour('Blue'))
|
||||||
|
|
||||||
bmp = wxBitmap('CalBmp/Calend.bmp', wxBITMAP_TYPE_BMP)
|
bmp = wxBitmap('Calbmp/Calend.bmp', wxBITMAP_TYPE_BMP)
|
||||||
self.but = wxBitmapButton(self, 160, bmp, wxPoint(380, 180), wxSize(30, 30))
|
self.but = wxBitmapButton(self, 160, bmp, wxPoint(380, 180))#, wxSize(30, 30))
|
||||||
EVT_BUTTON(self, 160, self.TestFrame)
|
EVT_BUTTON(self, 160, self.TestFrame)
|
||||||
|
|
||||||
# calendar dialog
|
# calendar dialog
|
||||||
@ -127,9 +123,8 @@ class TestPanel(wxPanel):
|
|||||||
# calendar window test
|
# calendar window test
|
||||||
|
|
||||||
def TestFrame(self, event):
|
def TestFrame(self, event):
|
||||||
frame = CalendFrame(NULL, -1, "Test Calendar", self.log)
|
frame = CalendFrame(self, -1, "Test Calendar", self.log)
|
||||||
frame.Show(true)
|
frame.Show(true)
|
||||||
self.SetTopWindow(frame)
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
# month and year control events
|
# month and year control events
|
||||||
@ -243,7 +238,7 @@ class CalenDlg(wxDialog):
|
|||||||
|
|
||||||
# set the calendar and attributes
|
# set the calendar and attributes
|
||||||
|
|
||||||
self.calend = Calendar(self, -1, wxPoint(20, 60), wxSize(240, 200))
|
self.calend = wxCalendar(self, -1, wxPoint(20, 60), wxSize(240, 200))
|
||||||
self.calend.SetMonth(start_month)
|
self.calend.SetMonth(start_month)
|
||||||
self.calend.SetYear(start_year)
|
self.calend.SetYear(start_year)
|
||||||
|
|
||||||
@ -313,7 +308,7 @@ class CalendFrame(wxFrame):
|
|||||||
self.MakeToolMenu() # toolbar
|
self.MakeToolMenu() # toolbar
|
||||||
|
|
||||||
self.SetMenuBar(self.mainmenu)
|
self.SetMenuBar(self.mainmenu)
|
||||||
self.calend = Calendar(self, -1)
|
self.calend = wxCalendar(self, -1)
|
||||||
self.calend.SetCurrentDay()
|
self.calend.SetCurrentDay()
|
||||||
self.calend.grid_color = 'BLUE'
|
self.calend.grid_color = 'BLUE'
|
||||||
self.ResetDisplay()
|
self.ResetDisplay()
|
||||||
@ -379,7 +374,7 @@ class CalendFrame(wxFrame):
|
|||||||
def MakeToolMenu(self):
|
def MakeToolMenu(self):
|
||||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||||
|
|
||||||
bmp_path = 'CalBmp/'
|
bmp_path = 'Calbmp/'
|
||||||
SetToolPath(self, tb, 10, bmp_path + 'DbDec.bmp', 'Dec Year')
|
SetToolPath(self, tb, 10, bmp_path + 'DbDec.bmp', 'Dec Year')
|
||||||
EVT_TOOL(self, 10, self.OnDecYear)
|
EVT_TOOL(self, 10, self.OnDecYear)
|
||||||
|
|
||||||
@ -401,6 +396,7 @@ def SetToolPath(self, tb, id, bmp, title):
|
|||||||
global dir_path
|
global dir_path
|
||||||
tb.AddTool(id, wxBitmap(os.path.join(dir_path, bmp), wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, title, title)
|
tb.AddTool(id, wxBitmap(os.path.join(dir_path, bmp), wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, title, title)
|
||||||
|
|
||||||
|
|
||||||
class MyApp(wxApp):
|
class MyApp(wxApp):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
frame = CalendFrame(NULL, -1, "Test Calendar")
|
frame = CalendFrame(NULL, -1, "Test Calendar")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#! /usr/local/bin/python
|
#! /usr/local/bin/python
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Name: wxCalend.py
|
# Name: calendar.py
|
||||||
# Purpose: Calendar display control
|
# Purpose: Calendar display control
|
||||||
#
|
#
|
||||||
# Author: Lorne White (email: lwhite1@planet.eon.net)
|
# Author: Lorne White (email: lwhite1@planet.eon.net)
|
||||||
@ -12,17 +12,13 @@
|
|||||||
|
|
||||||
from wxPython.wx import *
|
from wxPython.wx import *
|
||||||
|
|
||||||
try:
|
from CDate import *
|
||||||
from DateTime import *
|
|
||||||
using_mxDateTime = true
|
|
||||||
except ImportError:
|
|
||||||
from CDate import *
|
|
||||||
using_mxDateTime = false
|
|
||||||
|
|
||||||
import string, time
|
import string, time
|
||||||
|
|
||||||
|
|
||||||
CalDays = [6, 0, 1, 2, 3, 4, 5]
|
CalDays = [6, 0, 1, 2, 3, 4, 5]
|
||||||
AbrWeekday = {6:"Sun", 0:"Mon", 1:"Tue", 2:"Wed", 3:"Thu", 4:"Fri", 5:"Sat"}
|
AbrWeekday = {6:"Sun", 0:"Mon", 1:"Tue", 2:"Wed", 3:"Thu", 4:"Fri", 5:"Sat"}
|
||||||
|
_MIDSIZE = 100
|
||||||
|
|
||||||
|
|
||||||
# calendar drawing routing
|
# calendar drawing routing
|
||||||
@ -109,10 +105,10 @@ class CalDraw:
|
|||||||
month = Month[self.month]
|
month = Month[self.month]
|
||||||
|
|
||||||
sizef = 12
|
sizef = 12
|
||||||
if self.sizeh < 200:
|
if self.sizeh < _MIDSIZE:
|
||||||
sizef = 8
|
sizef = 10
|
||||||
|
|
||||||
f = wxFont(sizef, self.font, wxNORMAL, wxNORMAL)
|
f = wxFont(sizef, self.font, wxNORMAL, self.bold)
|
||||||
self.DC.SetFont(f)
|
self.DC.SetFont(f)
|
||||||
|
|
||||||
tw,th = self.DC.GetTextExtent(month)
|
tw,th = self.DC.GetTextExtent(month)
|
||||||
@ -125,18 +121,18 @@ class CalDraw:
|
|||||||
|
|
||||||
self.y_st = th * 3
|
self.y_st = th * 3
|
||||||
|
|
||||||
f = wxFont(sizef, self.font, wxNORMAL, wxNORMAL)
|
f = wxFont(sizef, self.font, wxNORMAL, self.bold)
|
||||||
self.DC.SetFont(f)
|
self.DC.SetFont(f)
|
||||||
self.DC.DrawText(year, adjust, 10)
|
self.DC.DrawText(year, adjust, 10)
|
||||||
|
|
||||||
# draw the week days
|
# draw the week days
|
||||||
|
|
||||||
def DrawWeek(self):
|
def DrawWeek(self):
|
||||||
sizef = 8
|
sizef = 10
|
||||||
if self.sizeh < 300:
|
if self.sizeh < _MIDSIZE:
|
||||||
sizef = 6
|
sizef = 8
|
||||||
|
|
||||||
f = wxFont(sizef, self.font, wxNORMAL, wxNORMAL)
|
f = wxFont(sizef, self.font, wxNORMAL, self.bold)
|
||||||
self.DC.SetFont(f)
|
self.DC.SetFont(f)
|
||||||
|
|
||||||
cnt_x = 0
|
cnt_x = 0
|
||||||
@ -160,10 +156,10 @@ class CalDraw:
|
|||||||
# draw the day numbers
|
# draw the day numbers
|
||||||
|
|
||||||
def DrawNum(self):
|
def DrawNum(self):
|
||||||
sizef = 9
|
sizef = 10
|
||||||
if self.sizeh < 260:
|
if self.sizeh < _MIDSIZE:
|
||||||
sizef = 6
|
sizef = 8
|
||||||
f = wxFont(sizef, self.font, wxNORMAL, wxNORMAL)
|
f = wxFont(sizef, self.font, wxNORMAL, self.bold)
|
||||||
self.DC.SetFont(f)
|
self.DC.SetFont(f)
|
||||||
|
|
||||||
cnt_x = 0
|
cnt_x = 0
|
||||||
@ -238,7 +234,7 @@ class CalDraw:
|
|||||||
y1 = y1 + self.dl_h
|
y1 = y1 + self.dl_h
|
||||||
|
|
||||||
|
|
||||||
class Calendar(wxWindow):
|
class wxCalendar(wxWindow):
|
||||||
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
||||||
wxWindow.__init__(self, parent, id, pos, size)
|
wxWindow.__init__(self, parent, id, pos, size)
|
||||||
|
|
||||||
@ -249,6 +245,7 @@ class Calendar(wxWindow):
|
|||||||
self.sel_color = 'RED'
|
self.sel_color = 'RED'
|
||||||
self.high_color = 'LIGHT BLUE'
|
self.high_color = 'LIGHT BLUE'
|
||||||
self.font = wxSWISS
|
self.font = wxSWISS
|
||||||
|
self.bold = wxNORMAL
|
||||||
|
|
||||||
self.SetBackgroundColour(wxNamedColor(self.back_color))
|
self.SetBackgroundColour(wxNamedColor(self.back_color))
|
||||||
self.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnLeftEvent)
|
self.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnLeftEvent)
|
||||||
@ -426,6 +423,7 @@ class Calendar(wxWindow):
|
|||||||
cal.high_color = self.high_color
|
cal.high_color = self.high_color
|
||||||
cal.back_color = self.back_color
|
cal.back_color = self.back_color
|
||||||
cal.font = self.font
|
cal.font = self.font
|
||||||
|
cal.bold = self.bold
|
||||||
|
|
||||||
cal.SetSize(size)
|
cal.SetSize(size)
|
||||||
cal.SetCal(self.year, self.month)
|
cal.SetCal(self.year, self.month)
|
||||||
|
Loading…
Reference in New Issue
Block a user