Updated WidgetUtils for WXPython 4

This commit is contained in:
Manuel Cortez 2018-09-02 07:33:09 -05:00
parent fc76b3929b
commit fc637e553c
2 changed files with 17 additions and 19 deletions

View File

@ -1,5 +1,5 @@
import platform import platform
#if platform.system() == "Windows": #if platform.system() == "Windows":
from wxUtils import * from .wxUtils import *
#elif platform.system() == "Linux": #elif platform.system() == "Linux":
# from gtkUtils import * # from gtkUtils import *

View File

@ -1,7 +1,4 @@
import wx import wx
import paths
import languageHandler
import sys
toolkit = "wx" toolkit = "wx"
@ -52,9 +49,10 @@ NOTEBOOK_PAGE_CHANGED = wx.EVT_TREEBOOK_PAGE_CHANGED
RADIOBUTTON = wx.EVT_RADIOBUTTON RADIOBUTTON = wx.EVT_RADIOBUTTON
# Taskbar mouse clicks. # Taskbar mouse clicks.
TASKBAR_RIGHT_CLICK = wx.EVT_TASKBAR_RIGHT_DOWN #TASKBAR_RIGHT_CLICK = wx.EVT_TASKBAR_RIGHT_DOWN
TASKBAR_LEFT_CLICK = wx.EVT_TASKBAR_LEFT_DOWN #TASKBAR_LEFT_CLICK = wx.EVT_TASKBAR_LEFT_DOWN
LISTBOX_CHANGED = wx.EVT_LISTBOX LISTBOX_CHANGED = wx.EVT_LISTBOX
LISTBOX_ITEM_ACTIVATED = wx.EVT_LIST_ITEM_ACTIVATED
def exit_application(): def exit_application():
""" Closes the current window cleanly. """ """ Closes the current window cleanly. """
@ -118,15 +116,15 @@ class mainLoopObject(wx.App):
def __init__(self): def __init__(self):
self.app = wx.App() self.app = wx.App()
self.lc = wx.Locale() # self.lc = wx.Locale()
lang=languageHandler.getLanguage() # lang=languageHandler.getLanguage()
wxLang=self.lc.FindLanguageInfo(lang) # wxLang=self.lc.FindLanguageInfo(lang)
if not wxLang and '_' in lang: # if not wxLang and '_' in lang:
wxLang=self.lc.FindLanguageInfo(lang.split('_')[0]) # wxLang=self.lc.FindLanguageInfo(lang.split('_')[0])
if hasattr(sys,'frozen'): # if hasattr(sys,'frozen'):
self.lc.AddCatalogLookupPathPrefix(paths.app_path("locales")) # self.lc.AddCatalogLookupPathPrefix(paths.app_path("locales"))
if wxLang: # if wxLang:
self.lc.Init(wxLang.Language) # self.lc.Init(wxLang.Language)
def run(self): def run(self):
self.app.MainLoop() self.app.MainLoop()
@ -145,16 +143,16 @@ class list(object):
def create_list(self, parent): def create_list(self, parent):
self.list = wx.ListCtrl(parent, -1, **self.listArguments) self.list = wx.ListCtrl(parent, -1, **self.listArguments)
for i in xrange(0, len(self.columns)): for i in range(0, len(self.columns)):
self.list.InsertColumn(i, u"%s" % (self.columns[i])) self.list.InsertColumn(i, u"%s" % (self.columns[i]))
def insert_item(self, reversed, *item): def insert_item(self, reversed, *item):
""" Inserts an item on the list.""" """ Inserts an item on the list."""
if reversed == False: items = self.list.GetItemCount() if reversed == False: items = self.list.GetItemCount()
else: items = 0 else: items = 0
self.list.InsertStringItem(items, item[0]) self.list.InsertItem(items, item[0])
for i in xrange(1, len(self.columns)): for i in range(1, len(self.columns)):
self.list.SetStringItem(items, i, item[i]) self.list.SetItem(items, i, item[i])
def remove_item(self, pos): def remove_item(self, pos):
""" Deletes an item from the list.""" """ Deletes an item from the list."""