mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
The keystroke editor now works properly
This commit is contained in:
parent
e7852e5e91
commit
b7193d16ee
@ -104,7 +104,7 @@ class Controller(object):
|
|||||||
def bind_other_events(self):
|
def bind_other_events(self):
|
||||||
""" Binds the local application events with their functions."""
|
""" Binds the local application events with their functions."""
|
||||||
log.debug("Binding other application events...")
|
log.debug("Binding other application events...")
|
||||||
pub.subscribe(self.editing_keystroke, "editing_keystroke")
|
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
|
||||||
pub.subscribe(self.manage_stream_errors, "stream-error")
|
pub.subscribe(self.manage_stream_errors, "stream-error")
|
||||||
pub.subscribe(self.create_new_buffer, "create-new-buffer")
|
pub.subscribe(self.create_new_buffer, "create-new-buffer")
|
||||||
pub.subscribe(self.restart_streams, "restart-streams")
|
pub.subscribe(self.restart_streams, "restart-streams")
|
||||||
@ -280,11 +280,22 @@ class Controller(object):
|
|||||||
search.timer.start()
|
search.timer.start()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def edit_keystrokes(self, event=None):
|
def edit_keystrokes(self, *args, **kwargs):
|
||||||
dlg = keystrokeEditor.keystrokeEditor()
|
editor = keystrokeEditor.KeystrokeEditor()
|
||||||
dlg.put_keystrokes(**config.app["keymap"])
|
if editor.changed == True:
|
||||||
dlg.ShowModal()
|
register = False
|
||||||
dlg.Destroy()
|
# determines if we need to reassign the keymap.
|
||||||
|
if self.showing == False:
|
||||||
|
register = True
|
||||||
|
elif config.app["app-settings"]["use_invisible_keyboard_shorcuts"] == True:
|
||||||
|
register = True
|
||||||
|
# If there is a keyboard handler instance we need unregister all old keystrokes before register the new ones.
|
||||||
|
if hasattr(self, "keyboard_handler"):
|
||||||
|
keymap = {}
|
||||||
|
for i in editor.hold_map:
|
||||||
|
if hasattr(self, i): keymap[editor.hold_map[i]] = getattr(self, i)
|
||||||
|
self.unregister_invisible_keyboard_shorcuts(keymap)
|
||||||
|
self.invisible_shorcuts_changed(registered=register)
|
||||||
|
|
||||||
def learn_sounds(self, *args, **kwargs):
|
def learn_sounds(self, *args, **kwargs):
|
||||||
""" Opens the sounds tutorial for the current account."""
|
""" Opens the sounds tutorial for the current account."""
|
||||||
@ -849,11 +860,11 @@ class Controller(object):
|
|||||||
if "followers" in buffer.session.settings["other_buffers"]["muted_buffers"]: return
|
if "followers" in buffer.session.settings["other_buffers"]["muted_buffers"]: return
|
||||||
self.notify(buffer.session, play_sound=play_sound)
|
self.notify(buffer.session, play_sound=play_sound)
|
||||||
buffer.add_new_item(data)
|
buffer.add_new_item(data)
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=buffer.session)
|
||||||
|
|
||||||
def manage_friend(self, data, user):
|
def manage_friend(self, data, user):
|
||||||
buffer = self.search_buffer("friends", user)
|
buffer = self.search_buffer("friends", user)
|
||||||
buffer.add_new_item(data)
|
buffer.add_new_item(data)
|
||||||
pub.sendMessage("restart-streams", streams=["main_stream"], session=buffer.session)
|
|
||||||
|
|
||||||
def manage_unfollowing(self, item, user):
|
def manage_unfollowing(self, item, user):
|
||||||
buffer = self.search_buffer("friends", user)
|
buffer = self.search_buffer("friends", user)
|
||||||
@ -940,9 +951,17 @@ class Controller(object):
|
|||||||
|
|
||||||
def restart_streams(self, streams=[], session=None):
|
def restart_streams(self, streams=[], session=None):
|
||||||
for i in streams:
|
for i in streams:
|
||||||
log.debug("Reconnecting the %s stream" % (i,))
|
log.debug("Restarting the %s stream" % (i,))
|
||||||
session.remove_stream(i)
|
session.remove_stream(i)
|
||||||
session.check_connection()
|
session.check_connection()
|
||||||
|
|
||||||
|
def invisible_shorcuts_changed(self, registered):
|
||||||
|
if registered == True:
|
||||||
|
km = self.create_invisible_keyboard_shorcuts()
|
||||||
|
self.register_invisible_keyboard_shorcuts(km)
|
||||||
|
elif registered == False:
|
||||||
|
km = self.create_invisible_keyboard_shorcuts()
|
||||||
|
self.unregister_invisible_keyboard_shorcuts(km)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
config.app.write()
|
config.app.write()
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from wxUI.dialogs import userActions
|
from wxUI.dialogs import userActions
|
||||||
|
from pubsub import pub
|
||||||
import re
|
import re
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import output
|
import output
|
||||||
@ -23,6 +24,7 @@ class userActionsController(object):
|
|||||||
def follow(self, user):
|
def follow(self, user):
|
||||||
try:
|
try:
|
||||||
self.session.twitter.twitter.create_friendship(screen_name=user )
|
self.session.twitter.twitter.create_friendship(screen_name=user )
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=self.session)
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
|
||||||
@ -35,12 +37,14 @@ class userActionsController(object):
|
|||||||
def mute(self, user):
|
def mute(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.twitter.create_mute(screen_name=user )
|
id = self.session.twitter.twitter.create_mute(screen_name=user )
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=self.session)
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
|
||||||
def unmute(self, user):
|
def unmute(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.twitter.destroy_mute(screen_name=user )
|
id = self.session.twitter.twitter.destroy_mute(screen_name=user )
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=self.session)
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
|
||||||
@ -53,12 +57,14 @@ class userActionsController(object):
|
|||||||
def block(self, user):
|
def block(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.twitter.create_block(screen_name=user )
|
id = self.session.twitter.twitter.create_block(screen_name=user )
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=self.session)
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
|
||||||
def unblock(self, user):
|
def unblock(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.twitter.destroy_block(screen_name=user )
|
id = self.session.twitter.twitter.destroy_block(screen_name=user )
|
||||||
|
pub.sendMessage("restart-streams", streams=["main_stream"], session=self.session)
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
|
||||||
|
@ -1,3 +1 @@
|
|||||||
import platform
|
from keystrokeEditor import KeystrokeEditor
|
||||||
if platform.system() == "Windows":
|
|
||||||
from wxUI import *
|
|
@ -5,21 +5,23 @@ actions = {
|
|||||||
"down": _(u"Go down up on the current list"),
|
"down": _(u"Go down up on the current list"),
|
||||||
"left": _(u"Go to the previous tab"),
|
"left": _(u"Go to the previous tab"),
|
||||||
"right": _(u"Go to the next tab"),
|
"right": _(u"Go to the next tab"),
|
||||||
|
"next_account": _(u"Changes to the next account"),
|
||||||
|
"previous_account": _(u"Changes to the previous account"),
|
||||||
"conversation_up": _(u"Move up one tweet in the conversation"),
|
"conversation_up": _(u"Move up one tweet in the conversation"),
|
||||||
"conversation_down": _(u"Move down one tweet in the conversation"),
|
"conversation_down": _(u"Move down one tweet in the conversation"),
|
||||||
"show_hide": _(u"Show the graphical interface"),
|
"show_hide": _(u"Show the graphical interface"),
|
||||||
"compose": _(u"New tweet"),
|
"post_tweet": _(u"New tweet"),
|
||||||
"reply": _(u"Reply to a tweet"),
|
"post_reply": _(u"Reply to a tweet"),
|
||||||
"retweet": _(u"Retweet"),
|
"post_retweet": _(u"Retweet"),
|
||||||
"dm": _(u"Send direct message"),
|
"send_dm": _(u"Send direct message"),
|
||||||
"fav": _(u"Mark as favourite"),
|
"add_to_favourites": _(u"Mark as favourite"),
|
||||||
"unfav": _(u"Remove from favourites"),
|
"remove_from_favourites": _(u"Remove from favourites"),
|
||||||
"action": _(u"Open the actions dialogue"),
|
"action": _(u"Open the actions dialogue"),
|
||||||
"details": _(u"See user details"),
|
"details": _(u"See user details"),
|
||||||
"view": _(u"Show tweet"),
|
"view_item": _(u"Show tweet"),
|
||||||
"close": _(u"Quit"),
|
"exit": _(u"Quit"),
|
||||||
"open_timeline": _(u"Open user timeline"),
|
"open_timeline": _(u"Open user timeline"),
|
||||||
"delete_buffer": _(u"Remove buffer"),
|
"remove_buffer": _(u"Remove buffer"),
|
||||||
"url": _(u"Open URL on the current tweet, or further information for a friend or follower"),
|
"url": _(u"Open URL on the current tweet, or further information for a friend or follower"),
|
||||||
"audio": _(u"Attempt to play audio"),
|
"audio": _(u"Attempt to play audio"),
|
||||||
"volume_up": _(u"Increase volume by 5%"),
|
"volume_up": _(u"Increase volume by 5%"),
|
||||||
@ -30,7 +32,7 @@ actions = {
|
|||||||
"go_page_down": _(u"Move 20 elements down on the current list"),
|
"go_page_down": _(u"Move 20 elements down on the current list"),
|
||||||
"update_profile": _(u"Edit profile"),
|
"update_profile": _(u"Edit profile"),
|
||||||
"delete": _(u"Remove a tweet or direct message"),
|
"delete": _(u"Remove a tweet or direct message"),
|
||||||
"clear_list": _(u"Empty the buffer removing all the elements"),
|
"clear_buffer": _(u"Empty the buffer removing all the elements"),
|
||||||
"repeat_item": _(u"Listen the current message"),
|
"repeat_item": _(u"Listen the current message"),
|
||||||
"copy_to_clipboard": _(u"Copy to clipboard"),
|
"copy_to_clipboard": _(u"Copy to clipboard"),
|
||||||
"add_to_list": _(u"Add to list"),
|
"add_to_list": _(u"Add to list"),
|
||||||
@ -41,5 +43,8 @@ actions = {
|
|||||||
"search": _(u"Search on twitter"),
|
"search": _(u"Search on twitter"),
|
||||||
"edit_keystrokes": _(u"Shows the keystroke editor"),
|
"edit_keystrokes": _(u"Shows the keystroke editor"),
|
||||||
"view_user_lists": _(u"Show lists for a specified user"),
|
"view_user_lists": _(u"Show lists for a specified user"),
|
||||||
"get_more_items": _(u"Loads more items for the current buffer"),
|
"get_more_items": _(u"loads previous items to any buffer"),
|
||||||
|
"reverse_geocode": _(u"Get location of any tweet"),
|
||||||
|
"view_reverse_geocode": _(u"Displays the tweet's location in a dialog"),
|
||||||
|
"get_trending_topics": _(u"Creates a buffer for displaying trends for a desired place"),
|
||||||
}
|
}
|
56
src/keystrokeEditor/keystrokeEditor.py
Normal file
56
src/keystrokeEditor/keystrokeEditor.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import widgetUtils
|
||||||
|
import config
|
||||||
|
import wx_ui
|
||||||
|
import constants
|
||||||
|
|
||||||
|
class KeystrokeEditor(object):
|
||||||
|
def __init__(self):
|
||||||
|
super(KeystrokeEditor, self).__init__()
|
||||||
|
self.changed = False # Change it if the keyboard shorcuts are reassigned.
|
||||||
|
self.dialog = wx_ui.keystrokeEditorDialog()
|
||||||
|
self.map = config.app["keymap"]
|
||||||
|
# we need to copy the keymap before modify it, for unregistering the old keystrokes if is needed.
|
||||||
|
self.hold_map = self.map.copy()
|
||||||
|
self.dialog.put_keystrokes(constants.actions, self.map)
|
||||||
|
widgetUtils.connect_event(self.dialog.edit, widgetUtils.BUTTON_PRESSED, self.edit_keystroke)
|
||||||
|
self.dialog.get_response()
|
||||||
|
|
||||||
|
def edit_keystroke(self, *args, **kwargs):
|
||||||
|
action = self.dialog.actions[self.dialog.get_action()]
|
||||||
|
edit_dialog = wx_ui.editKeystrokeDialog()
|
||||||
|
self.set_keystroke(self.map[action], edit_dialog)
|
||||||
|
answer = edit_dialog.get_response()
|
||||||
|
if answer == widgetUtils.OK:
|
||||||
|
new_keystroke = self.get_edited_keystroke(edit_dialog)
|
||||||
|
print new_keystroke
|
||||||
|
if new_keystroke != self.map[action]:
|
||||||
|
self.changed = True
|
||||||
|
print "changed"
|
||||||
|
self.map[action] = new_keystroke
|
||||||
|
|
||||||
|
def set_keystroke(self, keystroke, dialog):
|
||||||
|
for i in keystroke.split("+"):
|
||||||
|
if hasattr(dialog, i):
|
||||||
|
dialog.set(i, True)
|
||||||
|
dialog.set("key", keystroke.split("+")[-1])
|
||||||
|
|
||||||
|
def get_edited_keystroke(self, dialog):
|
||||||
|
keys = []
|
||||||
|
if dialog.get("win") == False:
|
||||||
|
wx_ui.no_win_message()
|
||||||
|
return
|
||||||
|
if dialog.get("control") == True:
|
||||||
|
keys.append("control")
|
||||||
|
# if dialog.get("win") == True:
|
||||||
|
keys.append("win")
|
||||||
|
if dialog.get("alt") == True:
|
||||||
|
keys.append("alt")
|
||||||
|
if dialog.get("shift") == True:
|
||||||
|
keys.append("shift")
|
||||||
|
if dialog.get("key") != "":
|
||||||
|
keys.append(dialog.get("key"))
|
||||||
|
else:
|
||||||
|
wx_ui.no_key()
|
||||||
|
return
|
||||||
|
return "+".join(keys)
|
@ -1,111 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import config
|
|
||||||
import wx
|
|
||||||
import constants
|
|
||||||
from multiplatform_widgets import widgets
|
|
||||||
from constants import actions
|
|
||||||
from pubsub import pub
|
|
||||||
|
|
||||||
class keystrokeEditor(wx.Dialog):
|
|
||||||
def __init__(self):
|
|
||||||
super(keystrokeEditor, self).__init__(parent=None, id=-1, title=_(u"Keystroke editor"))
|
|
||||||
panel = wx.Panel(self)
|
|
||||||
self.actions = []
|
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
keysText = wx.StaticText(panel, -1, _(u"Select a keystroke to edit"))
|
|
||||||
self.keys = widgets.list(self, _(u"Action"), _(u"Keystroke"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(400, 450))
|
|
||||||
self.keys.list.SetFocus()
|
|
||||||
firstSizer = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
firstSizer.Add(keysText)
|
|
||||||
firstSizer.Add(self.keys.list)
|
|
||||||
edit = wx.Button(panel, -1, _(u"Edit"))
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.edit, edit)
|
|
||||||
edit.SetDefault()
|
|
||||||
|
|
||||||
close = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
|
|
||||||
secondSizer = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
secondSizer.Add(edit)
|
|
||||||
secondSizer.Add(close)
|
|
||||||
sizer.Add(firstSizer)
|
|
||||||
sizer.Add(secondSizer)
|
|
||||||
panel.SetSizerAndFit(sizer)
|
|
||||||
|
|
||||||
def put_keystrokes(self, **keystrokes):
|
|
||||||
for i in keystrokes:
|
|
||||||
action = actions[i]
|
|
||||||
self.actions.append(i)
|
|
||||||
keystroke = keystrokes[i]
|
|
||||||
self.keys.insert_item(False, *[action, keystroke])
|
|
||||||
|
|
||||||
def edit(self, ev):
|
|
||||||
action = self.actions[self.keys.get_selected()]
|
|
||||||
pub.sendMessage("editing_keystroke", action=action, parentDialog=self)
|
|
||||||
|
|
||||||
class editKeystroke(wx.Dialog):
|
|
||||||
def __init__(self, action, keystroke, keyboard_handler):
|
|
||||||
super(editKeystroke, self).__init__(parent=None, id=-1, title=_(u"Editing keystroke"))
|
|
||||||
self.parent = parent
|
|
||||||
self.keyboard_handler = keyboard_handler
|
|
||||||
self.action = action
|
|
||||||
self.keystroke = keystroke
|
|
||||||
panel = wx.Panel(self)
|
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
self.control = wx.CheckBox(panel, -1, _(u"Control"))
|
|
||||||
self.alt = wx.CheckBox(panel, -1, _(u"Alt"))
|
|
||||||
self.shift = wx.CheckBox(panel, -1, _(u"Shift"))
|
|
||||||
self.win = wx.CheckBox(panel, -1, _(u"Windows"))
|
|
||||||
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer1.Add(self.control)
|
|
||||||
sizer1.Add(self.alt)
|
|
||||||
sizer1.Add(self.shift)
|
|
||||||
sizer1.Add(self.win)
|
|
||||||
charLabel = wx.StaticText(panel, -1, _(u"Key"))
|
|
||||||
self.key = wx.TextCtrl(panel, -1)
|
|
||||||
# self.key.SetMaxLength(1)
|
|
||||||
sizer2 = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer2.Add(charLabel)
|
|
||||||
sizer2.Add(self.key)
|
|
||||||
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
|
||||||
ok.SetDefault()
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.ok, ok)
|
|
||||||
cancel = wx.Button(panel, wx.ID_CANCEL)
|
|
||||||
sizer3 = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer3.Add(ok)
|
|
||||||
sizer3.Add(cancel)
|
|
||||||
sizer.Add(sizer1)
|
|
||||||
sizer.Add(sizer2)
|
|
||||||
sizer.Add(sizer3)
|
|
||||||
panel.SetSizerAndFit(sizer)
|
|
||||||
self.set_default()
|
|
||||||
|
|
||||||
def set_default(self):
|
|
||||||
for i in self.keystroke.split("+"):
|
|
||||||
if hasattr(self, i):
|
|
||||||
key = getattr(self, i)
|
|
||||||
key.SetValue(True)
|
|
||||||
self.key.SetValue(self.keystroke.split("+")[-1])
|
|
||||||
|
|
||||||
def ok(self, ev):
|
|
||||||
keys = []
|
|
||||||
if self.win.GetValue() == False:
|
|
||||||
wx.MessageDialog(self, _(u"You need to use the Windows key"), _(u"Invalid keystroke"), wx.OK|wx.ICON_ERROR).ShowModal()
|
|
||||||
return
|
|
||||||
if self.control.GetValue() == True:
|
|
||||||
keys.append("control")
|
|
||||||
if self.win.GetValue() == True:
|
|
||||||
keys.append("win")
|
|
||||||
if self.alt.GetValue() == True:
|
|
||||||
keys.append("alt")
|
|
||||||
if self.shift.GetValue() == True:
|
|
||||||
keys.append("shift")
|
|
||||||
if self.key.GetValue() != "":
|
|
||||||
keys.append(self.key.GetValue())
|
|
||||||
else:
|
|
||||||
wx.MessageDialog(self, _(u"You must provide a character for the keystroke"), _(u"Invalid keystroke"), wx.ICON_ERROR).ShowModal()
|
|
||||||
return
|
|
||||||
config.main["keymap"][self.action] = "+".join(keys)
|
|
||||||
if self.keyboard_handler != None:
|
|
||||||
self.keyboard_handler.unregister_key(self.keystroke, getattr(self.parent, self.action))
|
|
||||||
self.keyboard_handler.register_key(config.main["keymap"][self.action], getattr(self.parent, self.action))
|
|
||||||
|
|
||||||
self.EndModal(wx.ID_OK)
|
|
74
src/keystrokeEditor/wx_ui.py
Normal file
74
src/keystrokeEditor/wx_ui.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import wx
|
||||||
|
from multiplatform_widgets import widgets
|
||||||
|
from wxUI.dialogs import baseDialog
|
||||||
|
|
||||||
|
class keystrokeEditorDialog(baseDialog.BaseWXDialog):
|
||||||
|
def __init__(self):
|
||||||
|
super(keystrokeEditorDialog, self).__init__(parent=None, id=-1, title=_(u"Keystroke editor"))
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
self.actions = []
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
keysText = wx.StaticText(panel, -1, _(u"Select a keystroke to edit"))
|
||||||
|
self.keys = widgets.list(self, _(u"Action"), _(u"Keystroke"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(400, 450))
|
||||||
|
self.keys.list.SetFocus()
|
||||||
|
firstSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
firstSizer.Add(keysText)
|
||||||
|
firstSizer.Add(self.keys.list)
|
||||||
|
self.edit = wx.Button(panel, -1, _(u"Edit"))
|
||||||
|
self.edit.SetDefault()
|
||||||
|
|
||||||
|
close = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
|
||||||
|
secondSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
secondSizer.Add(self.edit)
|
||||||
|
secondSizer.Add(close)
|
||||||
|
sizer.Add(firstSizer)
|
||||||
|
sizer.Add(secondSizer)
|
||||||
|
panel.SetSizerAndFit(sizer)
|
||||||
|
|
||||||
|
def put_keystrokes(self, actions, keystrokes):
|
||||||
|
for i in keystrokes:
|
||||||
|
action = actions[i]
|
||||||
|
self.actions.append(i)
|
||||||
|
keystroke = keystrokes[i]
|
||||||
|
self.keys.insert_item(False, *[action, keystroke])
|
||||||
|
|
||||||
|
def get_action(self):
|
||||||
|
return self.keys.get_selected()
|
||||||
|
|
||||||
|
class editKeystrokeDialog(baseDialog.BaseWXDialog):
|
||||||
|
def __init__(self):
|
||||||
|
super(editKeystrokeDialog, self).__init__(parent=None, id=-1, title=_(u"Editing keystroke"))
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
self.control = wx.CheckBox(panel, -1, _(u"Control"))
|
||||||
|
self.alt = wx.CheckBox(panel, -1, _(u"Alt"))
|
||||||
|
self.shift = wx.CheckBox(panel, -1, _(u"Shift"))
|
||||||
|
self.win = wx.CheckBox(panel, -1, _(u"Windows"))
|
||||||
|
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer1.Add(self.control)
|
||||||
|
sizer1.Add(self.alt)
|
||||||
|
sizer1.Add(self.shift)
|
||||||
|
sizer1.Add(self.win)
|
||||||
|
charLabel = wx.StaticText(panel, -1, _(u"Key"))
|
||||||
|
self.key = wx.TextCtrl(panel, -1)
|
||||||
|
sizer2 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer2.Add(charLabel)
|
||||||
|
sizer2.Add(self.key)
|
||||||
|
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
||||||
|
ok.SetDefault()
|
||||||
|
cancel = wx.Button(panel, wx.ID_CANCEL)
|
||||||
|
sizer3 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer3.Add(ok)
|
||||||
|
sizer3.Add(cancel)
|
||||||
|
sizer.Add(sizer1)
|
||||||
|
sizer.Add(sizer2)
|
||||||
|
sizer.Add(sizer3)
|
||||||
|
panel.SetSizerAndFit(sizer)
|
||||||
|
|
||||||
|
|
||||||
|
def no_win_message():
|
||||||
|
return wx.MessageDialog(None, _(u"You need to use the Windows key"), _(u"Invalid keystroke"), wx.OK|wx.ICON_ERROR).ShowModal()
|
||||||
|
|
||||||
|
def no_key():
|
||||||
|
return wx.MessageDialog(None, _(u"You must provide a character for the keystroke"), _(u"Invalid keystroke"), wx.ICON_ERROR).ShowModal()
|
@ -14,3 +14,12 @@ class BaseWXDialog(wx.Dialog):
|
|||||||
elif hasattr(control, "GetLabel"): return getattr(control, "GetLabel")()
|
elif hasattr(control, "GetLabel"): return getattr(control, "GetLabel")()
|
||||||
else: return -1
|
else: return -1
|
||||||
else: return 0
|
else: return 0
|
||||||
|
|
||||||
|
def set(self, control, text):
|
||||||
|
if hasattr(self, control):
|
||||||
|
control = getattr(self, control)
|
||||||
|
if hasattr(control, "SetValue"): return getattr(control, "SetValue")(text)
|
||||||
|
elif hasattr(control, "SetLabel"): return getattr(control, "SetLabel")(text)
|
||||||
|
elif hasattr(control, "ChangeValue"): return getattr(control, "ChangeValue")(text)
|
||||||
|
else: return -1
|
||||||
|
else: return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user