Created
August 14, 2018 06:09
-
-
Save feerrenrut/e344f66cb3d9f0ae34a34e60b83ea449 to your computer and use it in GitHub Desktop.
Compare check mark of `CheckListCtrlMixin` with `CheckListBox` when using wxPython 4.03 on Windows 10
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
withSetProcessDpiAware = False | |
import ctypes | |
if withSetProcessDpiAware: | |
ctypes.windll.user32.SetProcessDPIAware() | |
import wx | |
from wx.lib.mixins.listctrl import CheckListCtrlMixin | |
class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin): | |
def __init__(self, parent): | |
wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT) | |
CheckListCtrlMixin.__init__(self) | |
class TestPanel(wx.Panel): | |
def __init__(self, parent): | |
wx.Panel.__init__(self, parent, -1) | |
sizer = wx.BoxSizer(wx.VERTICAL) | |
sizer.Add(wx.StaticText(self, label="SetProcessDPIAware has been called: %s"%withSetProcessDpiAware)) | |
sampleList = ['zero', 'one', 'two'] | |
sizer.Add(wx.StaticText(self, label="CheckListCtrlMixin")) | |
lb = CheckListCtrl(self) | |
lb.InsertColumn(0, 'Item') | |
for i in sampleList: | |
lb.InsertItem(1, i) | |
lb.CheckItem(1) | |
sizer.Add(lb, flag=wx.EXPAND) | |
sizer.Add(wx.StaticText(self, label="CheckListBox")) | |
lb = wx.CheckListBox(self, choices=sampleList) | |
lb.SetCheckedItems([1,]) | |
sizer.Add(lb, flag=wx.EXPAND) | |
self.SetSizer(sizer) | |
#---------------------------------------------------------------------- | |
class RunDemoApp(wx.App): | |
def __init__(self): | |
wx.App.__init__(self, redirect=False) | |
def OnInit(self): | |
frame = wx.Frame(None, -1, "test", pos=(50,50), size=(200,100), | |
style=wx.DEFAULT_FRAME_STYLE, name="test") | |
frame.Show(True) | |
win = TestPanel(frame) | |
# so set the frame to a good size for showing stuff | |
frame.SetSize((640, 480)) | |
win.SetFocus() | |
self.window = win | |
self.SetTopWindow(frame) | |
self.frame = frame | |
return True | |
def OnExitApp(self, evt): | |
self.frame.Close(True) | |
if __name__ == "__main__": | |
app = RunDemoApp() | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment