I got the same results as you when I ran test.py and displayed the âAboutâ dialog. I am using Python 3.10.12 + wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1 on Linux Mint 21.2.
The problem was due to how the AboutDialog
class was being declared. It should be derived from AboutDlgBase
, not wx.Dialog
. In its __init__()
method it should only call AboutDlgBase.__init__()
and not wx.Dialog.__init__()
.
The version below works for me.
# -----------------------------------------------------------
# adapted from
#
# Created
# -----------------------------------------------------------
import os
import sys
from wpAboutDlgBase import AboutDlgBase
import wx
#import wpSkGlobal as gl
#import wpConfig as wpConf
# -------------------------------------------
def version():
"""
Returns a string containing version and port info
"""
if wx.Port == '__WXMSW__':
port = 'msw'
elif wx.Port == '__WXMAC__':
if 'wxOSX-carbon' in wx.PlatformInfo:
port = 'osx-carbon'
else:
port = 'osx-cocoa'
elif wx.Port == '__WXGTK__':
port = 'gtk'
if 'gtk2' in wx.PlatformInfo:
port = 'gtk2'
elif 'gtk3' in wx.PlatformInfo:
port = 'gtk3'
else:
port = '???'
return "%s (phoenix)" % ( port)
########################################################################
class AboutDialog(AboutDlgBase):
"""
Creates and displays the About dialog
"""
#----------------------------------------------------------------------
def __init__(self):
"""
"""
AboutDlgBase.__init__(self,None)
from datetime import datetime
now = datetime.now()
day = now.strftime(("Date: %m/%d/%Y"))
self.m_staticTextDate.SetLabelText( str(day))
self.m_staticTextwxPythonVer.SetLabelText(wx.VERSION_STRING )
py_version = sys.version.split()[0]
self.m_staticTextPythonVer.SetLabelText(str(py_version ))
cpu = version()
self.m_staticTextOsName.SetLabelText(cpu)
#sys.version_info(major=3, minor=10, micro=4, releaselevel='final', serial=0)
# print(sys.version_info)
# print("sys.platform = %s" %(sys.platform)) # 'linux
self.m_staticTextPlatform.SetLabelText(sys.platform)
# if "__WXGTK__" in wx.PlatformInfo:
# pass # GTK
# elif "__WXMSW__" in wx.PlatformInfo:
# pass # Windows
# # if run directly as dialog
# print("sys.argv = %s" %(sys.argv))
# print("="*60) # print a separator line
# print(wx.PlatformInfo )
# under Mint outputs:
#('__WXGTK__', 'wxGTK', 'unicode', 'unicode-wchar', 'gtk3',
# 'wx-assertions-on', 'phoenix', 'wxWidgets 3.2.0', 'autoidman',
# 'sip-6.6.2', 'build-type: development')
# ---------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App()
dlg = AboutDialog()
dlg.ShowModal()
dlg.Destroy()
# ------------------------------- eof ------------------------------