mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 04:48:09 -06:00
next-gen: updated widgetUtils
This commit is contained in:
parent
567e612c72
commit
ca288de515
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*~
|
*~
|
||||||
windows-dependencies/*
|
windows-dependencies/
|
||||||
src/build/
|
src/build/
|
||||||
src/dist/
|
src/dist/
|
||||||
src/config/
|
src/config/
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
import platform
|
#import platform
|
||||||
if platform.system() == "Windows":
|
#if platform.system() == "Windows":
|
||||||
from wxUtils import *
|
from wxUtils import *
|
||||||
|
from baseDialog import *
|
||||||
|
#elif platform.system() == "Linux":
|
||||||
|
# from gtkUtils import *
|
||||||
|
16
src/widgetUtils/baseDialog.py
Normal file
16
src/widgetUtils/baseDialog.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import wx
|
||||||
|
|
||||||
|
class BaseWXDialog(wx.Dialog):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(BaseWXDialog, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def get_response(self):
|
||||||
|
return self.ShowModal()
|
||||||
|
|
||||||
|
def get(self, control):
|
||||||
|
if hasattr(self, control):
|
||||||
|
control = getattr(self, control)
|
||||||
|
if hasattr(control, "GetValue"): return getattr(control, "GetValue")()
|
||||||
|
elif hasattr(control, "GetLabel"): return getattr(control, "GetLabel")()
|
||||||
|
else: return -1
|
||||||
|
else: return 0
|
38
src/widgetUtils/gtkUtils.py
Normal file
38
src/widgetUtils/gtkUtils.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from gi.repository import Gtk, Gdk
|
||||||
|
|
||||||
|
# Code responses for GTK +3 dialogs.
|
||||||
|
# this is when an user presses OK on a dialogue.
|
||||||
|
OK = Gtk.ResponseType.OK
|
||||||
|
# This is when an user presses cancel on a dialogue.
|
||||||
|
CANCEL = Gtk.ResponseType.CANCEL
|
||||||
|
# This is when an user closes the dialogue or an id to create the close button.
|
||||||
|
CLOSE = Gtk.ResponseType.CLOSE
|
||||||
|
# The response for a "yes" Button pressed on a dialogue.
|
||||||
|
YES = Gtk.ResponseType.YES
|
||||||
|
# This is when the user presses No on a default dialogue.
|
||||||
|
NO = Gtk.ResponseType.NO
|
||||||
|
|
||||||
|
#events
|
||||||
|
# This is raised when the application must be closed.
|
||||||
|
CLOSE_EVENT = "delete-event"
|
||||||
|
# This is activated when a button is pressed.
|
||||||
|
BUTTON_PRESSED = "clicked"
|
||||||
|
# This is activated when an user enter text on an edit box.
|
||||||
|
#ENTERED_TEXT = wx.EVT_TEXT
|
||||||
|
MENU = "activate"
|
||||||
|
|
||||||
|
#KEYPRESS = wx.EVT_CHAR_HOOK
|
||||||
|
#NOTEBOOK_PAGE_CHANGED = wx.EVT_NOTEBOOK_PAGE_CHANGED
|
||||||
|
def exit_application():
|
||||||
|
""" Closes the current window cleanly. """
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def connect_event(parent, event, func, menuitem=None, *args, **kwargs):
|
||||||
|
""" Connects an event to a function.
|
||||||
|
parent Gtk.widget: The widget that will listen for the event.
|
||||||
|
event widgetUtils.event: The event that will be listened for the parent. The event should be one of the widgetUtils events.
|
||||||
|
function func: The function that will be connected to the event."""
|
||||||
|
if menuitem == None:
|
||||||
|
return getattr(parent, "connect")(event, func, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
return getattr(menuitem, "connect")(event, func, *args, **kwargs)
|
@ -19,14 +19,20 @@ CLOSE_EVENT = wx.EVT_CLOSE
|
|||||||
BUTTON_PRESSED = wx.EVT_BUTTON
|
BUTTON_PRESSED = wx.EVT_BUTTON
|
||||||
# This is activated when an user enter text on an edit box.
|
# This is activated when an user enter text on an edit box.
|
||||||
ENTERED_TEXT = wx.EVT_TEXT
|
ENTERED_TEXT = wx.EVT_TEXT
|
||||||
|
MENU = wx.EVT_MENU
|
||||||
|
KEYPRESS = wx.EVT_CHAR_HOOK
|
||||||
|
KEYUP = wx.EVT_KEY_UP
|
||||||
|
NOTEBOOK_PAGE_CHANGED = wx.EVT_NOTEBOOK_PAGE_CHANGED
|
||||||
def exit_application():
|
def exit_application():
|
||||||
""" Closes the current window cleanly. """
|
""" Closes the current window cleanly. """
|
||||||
wx.GetApp().ExitMainLoop()
|
wx.GetApp().ExitMainLoop()
|
||||||
|
|
||||||
def connect_event(parent, event, func):
|
def connect_event(parent, event, func, menuitem=None, *args, **kwargs):
|
||||||
""" Connects an event to a function.
|
""" Connects an event to a function.
|
||||||
parent wx.window: The widget that will listen for the event.
|
parent wx.window: The widget that will listen for the event.
|
||||||
event widgetUtils.event: The event that will be listened for the parent. The event should be one of the widgetUtils events.
|
event widgetUtils.event: The event that will be listened for the parent. The event should be one of the widgetUtils events.
|
||||||
function func: The function that will be connected to the event."""
|
function func: The function that will be connected to the event."""
|
||||||
return getattr(parent, "Bind")(event, func)
|
if menuitem == None:
|
||||||
|
return getattr(parent, "Bind")(event, func, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
return getattr(parent, "Bind")(event, func, menuitem, *args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user