hi all, the following script (reduced versione of the original) works fine on
windows (both XP and Vista) and I need to make it work also on Mac.
The
problem is that wxMac uses a different default font size and the text results
misplaced. I've tried to force the same font size as on windows but on screen
nothing changes on wxmac. The line in the script below that forces the font
size sets it to a great size (36) in order to make the change more evident on
the word 'CLIENTE:')
Is there any chance to circumvent this problem or maybe
am I using the wrong approach? I am using the last version of wxpython, python
2.5, Mac OS X 10.5.6
thanks in advance for your suggestions
Marco
···
######################
# -*- coding: windows-1252 -*-
import os
import time,
locale,datetime
import wx
import wx.html as html
import wx.lib.wxpTag
import
sqlite3,os,os.path,sys #agmod,sys
import wx.lib.intctrl
campi=
[('nome','stringa','CLIENTE:',(6, 15),(65, 13),(355, -1), False, 20 ),
]
class TestPanel(wx.Panel):
def __init__(self, parent, id=-1,
size=wx.DefaultSize, bgcolor=None):
wx.Panel.__init__(self, parent, id,
size=size)
self.GetParent().pann=self
if wx.Platform
=='__WXMAC__':
f=self.GetFont()
f.SetPointSize(36)
self.SetFont(f)
self.campi=campi
if bgcolor:
self.SetBackgroundColour(bgcolor)
#questo ciclo sostituisce
tutte le dichiarazioni esplicite precedenti e le variabili membro sono
#gestite da questo dizionario
self.diz_var = {}
for field in
self.campi:
wx.StaticText(self, -1, field[2], field
[3])
genitore = self.GetParent().GetParent()
nonno
= genitore.GetParent()
self.main_frame = nonno
print self.
GetFont().GetPointSize()
base_html="""<?xml version="1.0" encoding="windows-
1252"?>
<html>
<head>
<title>wxHTML does wxPython!</title>
</head>
<body
bgcolor="#00BFFF">
<h2><center>CUSTOMER ACTIVITY FORM</h2>
<center>Modificare i
dati e premere "Registra" per memorizzare le modifiche
<wxp module="main"
class="TestPanel" width=640 height=%d>
</wxp>
<p><hr><p>
</center>
</body></html>
""" % (campi[-1][3][1]+50)
class MySplitter(wx.SplitterWindow):
def __init__(self, parent, ID):
wx.SplitterWindow.__init__(self,
parent, ID,
style = wx.SP_LIVE_UPDATE
)
self.Bind(wx.
EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
self.Bind(wx.
EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
def
OnSashChanged(self, evt):
pass
def OnSashChanging(self, evt):
pass
SB_INFO = 0
SB_ROWCOL = 1
SB_DATETIME = 2
#-------------------------------------------------------------------------------
# --- our frame class
class smallAppFrame(wx.Frame):
def __init__
(self, parent, id, title):
wx.Frame.__init__(self, parent = None, id =
-1,
title = title,
pos = wx.
Point(100, 10), size = wx.Size(480, 640),
name = '',
style = wx.DEFAULT_FRAME_STYLE)
sb = self.CreateStatusBar(3)
sb.SetStatusWidths([-1, 65, 150])
sb.PushStatusText("Ready", SB_INFO)
splitter = MySplitter(self,-1)
p1 = wx.ListCtrl(splitter,-1,
style=wx.LC_REPORT )
p1.InsertColumn(0, "Contatto")
p1.
SetColumnWidth(0, 200)
self.p1=p1
self.html= html.HtmlWindow
(splitter, -1)
splitter.SetMinimumPaneSize(20)
splitter.
SplitVertically(p1, self.html, 100)
self.sizer = wx.BoxSizer
(wx.VERTICAL)
self.sizer.Add(splitter, 1, wx.EXPAND)
self.html.
SetPage(base_html)
self.b = base_html
self.SetSizer(self.
sizer)
self.SetAutoLayout(True)
self.sizer.SetSizeHints
(self)
self.Show(True)
#-------------------------------------------------------------------------------
app = wx.PySimpleApp()
language='it_IT'
li = wx.Locale.FindLanguageInfo
(language)
loc = wx.Locale(li.Language)
frame = smallAppFrame(None, -1, title="
My app")
app.MainLoop()