mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Next-gen: Audio uploader is now MVC, so tweets can include audios. Sounds tutorial is MVC and has been improved.
This commit is contained in:
parent
ca288de515
commit
2895d02cdc
@ -11,6 +11,7 @@ from mysc.repeating_timer import RepeatingTimer
|
|||||||
import config
|
import config
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import platform
|
import platform
|
||||||
|
from extra import SoundsTutorial
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
import keystrokeEditor
|
import keystrokeEditor
|
||||||
|
|
||||||
@ -174,6 +175,9 @@ class Controller(object):
|
|||||||
dlg.ShowModal()
|
dlg.ShowModal()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
def learn_sounds(self, *args, **kwargs):
|
||||||
|
SoundsTutorial.soundsTutorial()
|
||||||
|
|
||||||
def view_user_lists(self, users):
|
def view_user_lists(self, users):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -3,16 +3,19 @@ import widgetUtils
|
|||||||
import output
|
import output
|
||||||
import url_shortener
|
import url_shortener
|
||||||
import sound
|
import sound
|
||||||
|
from pubsub import pub
|
||||||
from wxUI.dialogs import message, urlList
|
from wxUI.dialogs import message, urlList
|
||||||
from extra import translator, SpellChecker
|
from extra import translator, SpellChecker
|
||||||
|
from extra.AudioUploader import audioUploader
|
||||||
from twitter import utils
|
from twitter import utils
|
||||||
|
|
||||||
class tweet(object):
|
class tweet(object):
|
||||||
def __init__(self, session):
|
def __init__(self, session):
|
||||||
super(tweet, self).__init__()
|
super(tweet, self).__init__()
|
||||||
|
self.session = session
|
||||||
self.message = message.tweet(_(u"Write the tweet here"), _(u"tweet - 0 characters"), "")
|
self.message = message.tweet(_(u"Write the tweet here"), _(u"tweet - 0 characters"), "")
|
||||||
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
|
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
|
||||||
# widgetUtils.connect_event(self.message.attach, widgetUtils.BUTTON_PRESSED, self.attach)
|
widgetUtils.connect_event(self.message.attach, widgetUtils.BUTTON_PRESSED, self.attach)
|
||||||
widgetUtils.connect_event(self.message.text, widgetUtils.ENTERED_TEXT, self.text_processor)
|
widgetUtils.connect_event(self.message.text, widgetUtils.ENTERED_TEXT, self.text_processor)
|
||||||
widgetUtils.connect_event(self.message.shortenButton, widgetUtils.BUTTON_PRESSED, self.shorten)
|
widgetUtils.connect_event(self.message.shortenButton, widgetUtils.BUTTON_PRESSED, self.shorten)
|
||||||
widgetUtils.connect_event(self.message.unshortenButton, widgetUtils.BUTTON_PRESSED, self.unshorten)
|
widgetUtils.connect_event(self.message.unshortenButton, widgetUtils.BUTTON_PRESSED, self.unshorten)
|
||||||
@ -76,4 +79,16 @@ class tweet(object):
|
|||||||
text = self.message.get_text()
|
text = self.message.get_text()
|
||||||
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
||||||
if hasattr(checker, "fixed_text"):
|
if hasattr(checker, "fixed_text"):
|
||||||
self.message.set_text(checker.fixed_text)
|
self.message.set_text(checker.fixed_text)
|
||||||
|
|
||||||
|
def attach(self, *args, **kwargs):
|
||||||
|
def completed_callback():
|
||||||
|
url = dlg.uploaderFunction.get_url()
|
||||||
|
pub.unsubscribe(dlg.uploaderDialog.update, "uploading")
|
||||||
|
dlg.uploaderDialog.destroy()
|
||||||
|
if url != 0:
|
||||||
|
self.message.set_text(self.message.get_text()+url+" #audio")
|
||||||
|
else:
|
||||||
|
output.speak(_(u"Unable to upload the audio"))
|
||||||
|
dlg.cleanup()
|
||||||
|
dlg = audioUploader.audioUploader(self.session.settings, completed_callback)
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
import gui, transfer, transfer_dialogs, platform
|
|
||||||
if platform.system() != "Darwin":
|
|
||||||
import dropbox
|
|
186
src/extra/AudioUploader/audioUploader.py
Normal file
186
src/extra/AudioUploader/audioUploader.py
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
############################################################
|
||||||
|
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
import widgetUtils
|
||||||
|
import wx_ui
|
||||||
|
import wx_transfer_dialogs
|
||||||
|
import dropbox_transfer, transfer
|
||||||
|
import output
|
||||||
|
import tempfile
|
||||||
|
import sound
|
||||||
|
import os
|
||||||
|
import config
|
||||||
|
from pubsub import pub
|
||||||
|
from mysc.thread_utils import call_threaded
|
||||||
|
import sound_lib
|
||||||
|
|
||||||
|
class audioUploader(object):
|
||||||
|
def __init__(self, configFile, completed_callback):
|
||||||
|
self.config = configFile
|
||||||
|
super(audioUploader, self).__init__()
|
||||||
|
self.dialog = wx_ui.audioDialog(services=self.get_available_services())
|
||||||
|
self.file = None
|
||||||
|
self.recorded = False
|
||||||
|
self.recording = None
|
||||||
|
self.playing = None
|
||||||
|
widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play)
|
||||||
|
widgetUtils.connect_event(self.dialog.pause, widgetUtils.BUTTON_PRESSED, self.on_pause)
|
||||||
|
widgetUtils.connect_event(self.dialog.record, widgetUtils.BUTTON_PRESSED, self.on_record)
|
||||||
|
widgetUtils.connect_event(self.dialog.attach_exists, widgetUtils.BUTTON_PRESSED, self.on_attach_exists)
|
||||||
|
widgetUtils.connect_event(self.dialog.discard, widgetUtils.BUTTON_PRESSED, self.on_discard)
|
||||||
|
if self.dialog.get_response() == widgetUtils.OK:
|
||||||
|
self.postprocess()
|
||||||
|
self.uploaderDialog = wx_transfer_dialogs.UploadDialog(self.file)
|
||||||
|
output.speak(_(u"Attaching..."))
|
||||||
|
if self.dialog.get("services") == "Dropbox":
|
||||||
|
self.uploaderFunction = dropbox_transfer.dropboxUploader(filename=self.file, completed_callback=completed_callback, config=self.config)
|
||||||
|
elif self.dialog.get("services") == "SNDUp":
|
||||||
|
base_url = "http://sndup.net/post.php"
|
||||||
|
if len(self.config["sound"]["sndup_api_key"]) > 0:
|
||||||
|
url = base_url + '?apikey=' + self.config['sound']['sndup_api_key']
|
||||||
|
else:
|
||||||
|
url = base_url
|
||||||
|
self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback)
|
||||||
|
elif self.dialog.get("services") == "TwUp":
|
||||||
|
url = "http://api.twup.me/post.json"
|
||||||
|
self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback)
|
||||||
|
pub.subscribe(self.uploaderDialog.update, "uploading")
|
||||||
|
self.uploaderDialog.get_response()
|
||||||
|
self.uploaderFunction.perform_threaded()
|
||||||
|
|
||||||
|
def get_available_services(self):
|
||||||
|
services = []
|
||||||
|
services.append("TwUp")
|
||||||
|
if self.config["services"]["dropbox_token"] != "":
|
||||||
|
services.append("Dropbox")
|
||||||
|
services.append("SNDUp")
|
||||||
|
return services
|
||||||
|
|
||||||
|
def on_pause(self, *args, **kwargs):
|
||||||
|
if self.dialog.get("pause") == _(u"Pause"):
|
||||||
|
self.recording.pause()
|
||||||
|
self.dialog.set("pause", _(u"Resume"))
|
||||||
|
elif self.dialog.get("pause") == _(u"Resume"):
|
||||||
|
self.recording.play()
|
||||||
|
self.dialog.set("pause", _(U"Pause"))
|
||||||
|
|
||||||
|
def on_record(self, *args, **kwargs):
|
||||||
|
if self.recording != None:
|
||||||
|
self.stop_recording()
|
||||||
|
self.dialog.disable_control("pause")
|
||||||
|
else:
|
||||||
|
self.start_recording()
|
||||||
|
self.dialog.enable_control("pause")
|
||||||
|
|
||||||
|
def start_recording(self):
|
||||||
|
self.dialog.disable_control("attach_exists")
|
||||||
|
self.file = tempfile.mktemp(suffix='.wav')
|
||||||
|
self.recording = sound.recording(self.file)
|
||||||
|
self.recording.play()
|
||||||
|
self.dialog.set("record", _(u"Stop recording"))
|
||||||
|
output.speak(_(u"Recording"))
|
||||||
|
|
||||||
|
def stop_recording(self):
|
||||||
|
self.recording.stop()
|
||||||
|
self.recording.free()
|
||||||
|
output.speak(_(u"Stopped"))
|
||||||
|
self.recorded = True
|
||||||
|
self.dialog.set("record", _(u"Record"))
|
||||||
|
self.file_attached()
|
||||||
|
|
||||||
|
def file_attached(self):
|
||||||
|
self.dialog.set("pause", _(u"Pause"))
|
||||||
|
self.dialog.disable_control("record")
|
||||||
|
self.dialog.enable_control("play")
|
||||||
|
self.dialog.enable_control("discard")
|
||||||
|
self.dialog.disable_control("attach_exists")
|
||||||
|
self.dialog.enable_control("attach")
|
||||||
|
self.dialog.play.SetFocus()
|
||||||
|
|
||||||
|
def on_discard(self, *args, **kwargs):
|
||||||
|
if self.playing:
|
||||||
|
self._stop()
|
||||||
|
if self.recording != None:
|
||||||
|
self.dialog.disable_control("attach")
|
||||||
|
self.dialog.disable_control("play")
|
||||||
|
self.file = None
|
||||||
|
self.dialog.enable_control("record")
|
||||||
|
self.dialog.enable_control("attach_exists")
|
||||||
|
self.dialog.record.SetFocus()
|
||||||
|
self.dialog.disable_control("discard")
|
||||||
|
self.recording = None
|
||||||
|
output.speak(_(u"Discarded"))
|
||||||
|
|
||||||
|
def on_play(self, *args, **kwargs):
|
||||||
|
if not self.playing:
|
||||||
|
call_threaded(self._play)
|
||||||
|
else:
|
||||||
|
self._stop()
|
||||||
|
|
||||||
|
def _play(self):
|
||||||
|
output.speak(_(u"Playing..."))
|
||||||
|
# try:
|
||||||
|
self.playing = sound_lib.stream.FileStream(file=unicode(self.file), flags=sound_lib.stream.BASS_UNICODE)
|
||||||
|
self.playing.play()
|
||||||
|
self.dialog.set("play", _(u"Stop"))
|
||||||
|
try:
|
||||||
|
while self.playing.is_playing:
|
||||||
|
pass
|
||||||
|
self.dialog.set("play", _(u"Play"))
|
||||||
|
self.playing.free()
|
||||||
|
self.playing = None
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _stop(self):
|
||||||
|
output.speak(_(u"Stopped"))
|
||||||
|
self.playing.stop()
|
||||||
|
self.playing.free()
|
||||||
|
self.dialog.set("play", _(u"Play"))
|
||||||
|
self.playing = None
|
||||||
|
|
||||||
|
def postprocess(self):
|
||||||
|
if self.file.lower().endswith('.wav'):
|
||||||
|
output.speak(_(u"Recoding audio..."))
|
||||||
|
sound.recode_audio(self.file)
|
||||||
|
self.wav_file = self.file
|
||||||
|
self.file = '%s.ogg' % self.file[:-4]
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
if self.playing and self.playing.is_playing:
|
||||||
|
self.playing.stop()
|
||||||
|
if self.recording != None:
|
||||||
|
if self.recording.is_playing:
|
||||||
|
self.recording.stop()
|
||||||
|
try:
|
||||||
|
self.recording.free()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
os.remove(self.file)
|
||||||
|
if hasattr(self, 'wav_file'):
|
||||||
|
os.remove(self.wav_file)
|
||||||
|
del(self.wav_file)
|
||||||
|
if hasattr(self, 'wav_file') and os.path.exists(self.file):
|
||||||
|
os.remove(self.file)
|
||||||
|
|
||||||
|
|
||||||
|
def on_attach_exists(self, *args, **kwargs):
|
||||||
|
self.file = self.dialog.get_file()
|
||||||
|
if self.file != False:
|
||||||
|
self.file_attached()
|
||||||
|
|
@ -3,13 +3,11 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import exceptions
|
import exceptions
|
||||||
import wx
|
|
||||||
import dropbox
|
import dropbox
|
||||||
import config
|
|
||||||
from mysc import event
|
|
||||||
from utils import *
|
from utils import *
|
||||||
from dropbox.rest import ErrorResponse
|
from dropbox.rest import ErrorResponse
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
from pubsub import pub
|
||||||
|
|
||||||
class UnauthorisedError(exceptions.Exception):
|
class UnauthorisedError(exceptions.Exception):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -39,10 +37,11 @@ class newChunkedUploader(dropbox.client.ChunkedUploader):
|
|||||||
self.offset = reply['offset']
|
self.offset = reply['offset']
|
||||||
|
|
||||||
class dropboxLogin(object):
|
class dropboxLogin(object):
|
||||||
def __init__(self):
|
def __init__(self, config):
|
||||||
self.logged = False
|
self.logged = False
|
||||||
self.app_key = "c8ikm0gexqvovol"
|
self.app_key = "c8ikm0gexqvovol"
|
||||||
self.app_secret = "gvvi6fzfecooast"
|
self.app_secret = "gvvi6fzfecooast"
|
||||||
|
self.config = config
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(self.app_key, self.app_secret)
|
self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(self.app_key, self.app_secret)
|
||||||
@ -50,18 +49,17 @@ class dropboxLogin(object):
|
|||||||
|
|
||||||
def authorise(self, code):
|
def authorise(self, code):
|
||||||
access_token, user_id = self.flow.finish(code)
|
access_token, user_id = self.flow.finish(code)
|
||||||
config.main["services"]["dropbox_token"] = access_token
|
config["services"]["dropbox_token"] = access_token
|
||||||
self.logged = True
|
self.logged = True
|
||||||
|
|
||||||
class dropboxUploader(object):
|
class dropboxUploader(object):
|
||||||
def __init__(self, filename, completed_callback, wxDialog, short_url=False):
|
def __init__(self, config, filename, completed_callback, short_url=False):
|
||||||
if config.main["services"]["dropbox_token"] != "":
|
if config["services"]["dropbox_token"] != "":
|
||||||
self.client = dropbox.client.DropboxClient(config.main["services"]["dropbox_token"])
|
self.client = dropbox.client.DropboxClient(config["services"]["dropbox_token"])
|
||||||
else:
|
else:
|
||||||
raise UnauthorisedError("You need authorise TWBlue")
|
raise UnauthorisedError("You need authorise TWBlue")
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.short_url = short_url
|
self.short_url = short_url
|
||||||
self.wxDialog = wxDialog
|
|
||||||
self.file = open(self.filename, "rb")
|
self.file = open(self.filename, "rb")
|
||||||
self.file_size = os.path.getsize(self.filename)
|
self.file_size = os.path.getsize(self.filename)
|
||||||
self.uploader = newChunkedUploader(client=self.client, file_obj=self.file, length=self.file_size, callback=self.process)
|
self.uploader = newChunkedUploader(client=self.client, file_obj=self.file, length=self.file_size, callback=self.process)
|
||||||
@ -94,9 +92,7 @@ class dropboxUploader(object):
|
|||||||
progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate
|
progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate
|
||||||
else:
|
else:
|
||||||
progress["eta"] = 0
|
progress["eta"] = 0
|
||||||
info = event.event(event.EVT_OBJECT, 1)
|
pub.sendMessage("uploading", data=progress)
|
||||||
info.SetItem(progress)
|
|
||||||
wx.PostEvent(self.wxDialog, info)
|
|
||||||
|
|
||||||
def perform_threaded(self):
|
def perform_threaded(self):
|
||||||
self.background_thread = threading.Thread(target=self.perform_transfer)
|
self.background_thread = threading.Thread(target=self.perform_transfer)
|
||||||
@ -109,5 +105,6 @@ class dropboxUploader(object):
|
|||||||
self.completed_callback()
|
self.completed_callback()
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
original = "%s" % (self.client.share(os.path.basename(self.filename), False)["url"])
|
original = "%s" % (self.client.media(os.path.basename(self.filename))["url"])
|
||||||
return original.replace("dl=0", "dl=1")
|
return original
|
||||||
|
# .replace("dl=0", "dl=1")
|
@ -1,190 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
############################################################
|
|
||||||
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
############################################################
|
|
||||||
import wx
|
|
||||||
import output
|
|
||||||
import tempfile
|
|
||||||
import sound
|
|
||||||
import os
|
|
||||||
import config
|
|
||||||
from mysc.thread_utils import call_threaded
|
|
||||||
import sound_lib
|
|
||||||
|
|
||||||
class audioDialog(wx.Dialog):
|
|
||||||
def __init__(self, parent):
|
|
||||||
self.parent = parent
|
|
||||||
wx.Dialog.__init__(self, None, -1, _(u"Attach audio"))
|
|
||||||
self.file = None
|
|
||||||
self.recorded = False
|
|
||||||
self.recording = None
|
|
||||||
self.playing = None
|
|
||||||
panel = wx.Panel(self)
|
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
self.play = wx.Button(panel, -1, _(u"Play"))
|
|
||||||
self.play.Bind(wx.EVT_BUTTON, self.onPlay)
|
|
||||||
self.play.Disable()
|
|
||||||
self.pause = wx.Button(panel, -1, _(u"Pause"))
|
|
||||||
self.pause.Bind(wx.EVT_BUTTON, self.onPause)
|
|
||||||
self.pause.Disable()
|
|
||||||
self.record = wx.Button(panel, -1, _(u"Record"))
|
|
||||||
self.record.Bind(wx.EVT_BUTTON, self.onRecord)
|
|
||||||
self.record.SetFocus()
|
|
||||||
self.attach_exists = wx.Button(panel, -1, _(u"Add an existing file"))
|
|
||||||
self.attach_exists.Bind(wx.EVT_BUTTON, self.onAttach)
|
|
||||||
self.discard = wx.Button(panel, -1, _(u"Discard"))
|
|
||||||
self.discard.Bind(wx.EVT_BUTTON, self.onDiscard)
|
|
||||||
self.discard.Disable()
|
|
||||||
label = wx.StaticText(panel, -1, _(u"Upload to"))
|
|
||||||
self.services = wx.ComboBox(panel, -1, choices=self.get_available_services(), value=self.get_available_services()[0], style=wx.CB_READONLY)
|
|
||||||
servicesBox = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
servicesBox.Add(label)
|
|
||||||
servicesBox.Add(self.services)
|
|
||||||
self.attach = wx.Button(panel, wx.ID_OK, _(u"Attach"))
|
|
||||||
self.attach.Disable()
|
|
||||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
|
||||||
sizer.Add(self.play)
|
|
||||||
sizer.Add(self.pause)
|
|
||||||
sizer.Add(self.record)
|
|
||||||
sizer.Add(self.attach_exists)
|
|
||||||
sizer.Add(self.discard)
|
|
||||||
sizer.Add(self.attach)
|
|
||||||
|
|
||||||
def get_available_services(self):
|
|
||||||
services = []
|
|
||||||
if config.main["services"]["dropbox_token"] != "":
|
|
||||||
services.append("Dropbox")
|
|
||||||
services.append("SNDUp")
|
|
||||||
return services
|
|
||||||
|
|
||||||
def onPause(self, ev):
|
|
||||||
if self.pause.GetLabel() == _(u"Pause"):
|
|
||||||
self.recording.pause()
|
|
||||||
self.pause.SetLabel(_(u"Resume"))
|
|
||||||
elif self.pause.GetLabel() == _(u"Resume"):
|
|
||||||
self.recording.play()
|
|
||||||
self.pause.SetLabel(_(U"Pause"))
|
|
||||||
|
|
||||||
def onRecord(self, ev):
|
|
||||||
if self.recording != None:
|
|
||||||
self.stop_recording()
|
|
||||||
self.pause.Disable()
|
|
||||||
else:
|
|
||||||
self.start_recording()
|
|
||||||
self.pause.Enable()
|
|
||||||
|
|
||||||
def start_recording(self):
|
|
||||||
self.attach_exists.Disable()
|
|
||||||
self.file = tempfile.mktemp(suffix='.wav')
|
|
||||||
self.recording = sound.recording(self.file)
|
|
||||||
self.recording.play()
|
|
||||||
self.record.SetLabel(_(u"Stop recording"))
|
|
||||||
output.speak(_(u"Recording"))
|
|
||||||
|
|
||||||
def stop_recording(self):
|
|
||||||
self.recording.stop()
|
|
||||||
self.recording.free()
|
|
||||||
output.speak(_(u"Stopped"))
|
|
||||||
self.recorded = True
|
|
||||||
self.record.SetLabel(_(u"Record"))
|
|
||||||
self.file_attached()
|
|
||||||
|
|
||||||
def file_attached(self):
|
|
||||||
self.pause.SetLabel(_(u"Pause"))
|
|
||||||
self.record.Disable()
|
|
||||||
self.play.Enable()
|
|
||||||
self.discard.Enable()
|
|
||||||
self.attach_exists.Disable()
|
|
||||||
self.attach.Enable()
|
|
||||||
self.play.SetFocus()
|
|
||||||
|
|
||||||
def onDiscard(self, evt):
|
|
||||||
evt.Skip()
|
|
||||||
if self.playing:
|
|
||||||
self._stop()
|
|
||||||
if self.recording != None:
|
|
||||||
self.attach.Disable()
|
|
||||||
self.play.Disable()
|
|
||||||
self.file = None
|
|
||||||
self.record.Enable()
|
|
||||||
self.attach_exists.Enable()
|
|
||||||
self.record.SetFocus()
|
|
||||||
self.discard.Disable()
|
|
||||||
self.recording = None
|
|
||||||
output.speak(_(u"Discarded"))
|
|
||||||
|
|
||||||
def onPlay(self, evt):
|
|
||||||
evt.Skip()
|
|
||||||
if not self.playing:
|
|
||||||
call_threaded(self._play)
|
|
||||||
else:
|
|
||||||
self._stop()
|
|
||||||
|
|
||||||
def _play(self):
|
|
||||||
output.speak(_(u"Playing..."))
|
|
||||||
# try:
|
|
||||||
self.playing = sound_lib.stream.FileStream(file=unicode(self.file), flags=sound_lib.stream.BASS_UNICODE)
|
|
||||||
self.playing.play()
|
|
||||||
self.play.SetLabel(_(u"Stop"))
|
|
||||||
try:
|
|
||||||
while self.playing.is_playing:
|
|
||||||
pass
|
|
||||||
self.play.SetLabel(_(u"Play"))
|
|
||||||
self.playing.free()
|
|
||||||
self.playing = None
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _stop(self):
|
|
||||||
output.speak(_(u"Stopped"))
|
|
||||||
self.playing.stop()
|
|
||||||
self.playing.free()
|
|
||||||
self.play.SetLabel(_(u"Play"))
|
|
||||||
self.playing = None
|
|
||||||
|
|
||||||
def postprocess(self):
|
|
||||||
if self.file.lower().endswith('.wav'):
|
|
||||||
output.speak(_(u"Recoding audio..."))
|
|
||||||
sound.recode_audio(self.file)
|
|
||||||
self.wav_file = self.file
|
|
||||||
self.file = '%s.ogg' % self.file[:-4]
|
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
if self.playing and self.playing.is_playing:
|
|
||||||
self.playing.stop()
|
|
||||||
if self.recording != None:
|
|
||||||
if self.recording.is_playing:
|
|
||||||
self.recording.stop()
|
|
||||||
try:
|
|
||||||
self.recording.free()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
os.remove(self.file)
|
|
||||||
if hasattr(self, 'wav_file'):
|
|
||||||
os.remove(self.wav_file)
|
|
||||||
del(self.wav_file)
|
|
||||||
if hasattr(self, 'wav_file') and os.path.exists(self.file):
|
|
||||||
os.remove(self.file)
|
|
||||||
|
|
||||||
|
|
||||||
def onAttach(self, ev):
|
|
||||||
openFileDialog = wx.FileDialog(self, _(u"Select the audio file to be uploaded"), "", "", _("Audio Files (*.mp3, *.ogg, *.wav)|*.mp3; *.ogg; *.wav"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
|
||||||
if openFileDialog.ShowModal() == wx.ID_CANCEL:
|
|
||||||
return
|
|
||||||
self.file = openFileDialog.GetPath()
|
|
||||||
self.file_attached()
|
|
||||||
ev.Skip()
|
|
@ -4,15 +4,12 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import wx
|
|
||||||
from mysc import event
|
|
||||||
from utils import *
|
from utils import *
|
||||||
|
from pubsub import pub
|
||||||
#__all__ = ['TransferDialog', 'DownloadDialog', 'UploadDialog']
|
|
||||||
|
|
||||||
class Transfer(object):
|
class Transfer(object):
|
||||||
|
|
||||||
def __init__(self, url=None, filename=None, follow_location=True, completed_callback=None, verbose=False, wxDialog=None, *args, **kwargs):
|
def __init__(self, url=None, filename=None, follow_location=True, completed_callback=None, verbose=False, *args, **kwargs):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.curl = pycurl.Curl()
|
self.curl = pycurl.Curl()
|
||||||
@ -26,7 +23,6 @@ class Transfer(object):
|
|||||||
self.curl.setopt(self.curl.HTTP_VERSION, self.curl.CURL_HTTP_VERSION_1_0)
|
self.curl.setopt(self.curl.HTTP_VERSION, self.curl.CURL_HTTP_VERSION_1_0)
|
||||||
self.curl.setopt(self.curl.FOLLOWLOCATION, int(follow_location))
|
self.curl.setopt(self.curl.FOLLOWLOCATION, int(follow_location))
|
||||||
self.curl.setopt(self.curl.VERBOSE, int(verbose))
|
self.curl.setopt(self.curl.VERBOSE, int(verbose))
|
||||||
self.wxDialog = wxDialog
|
|
||||||
super(Transfer, self).__init__(*args, **kwargs)
|
super(Transfer, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def elapsed_time(self):
|
def elapsed_time(self):
|
||||||
@ -52,15 +48,13 @@ class Transfer(object):
|
|||||||
progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate
|
progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate
|
||||||
else:
|
else:
|
||||||
progress["eta"] = 0
|
progress["eta"] = 0
|
||||||
info = event.event(event.EVT_OBJECT, 1)
|
pub.sendMessage("uploading", data=progress)
|
||||||
info.SetItem(progress)
|
|
||||||
wx.PostEvent(self.wxDialog, info)
|
|
||||||
|
|
||||||
def perform_transfer(self):
|
def perform_transfer(self):
|
||||||
self.start_time = time.time()
|
self.start_time = time.time()
|
||||||
self.curl.perform()
|
self.curl.perform()
|
||||||
self.curl.close()
|
self.curl.close()
|
||||||
wx.CallAfter(self.complete_transfer)
|
self.complete_transfer()
|
||||||
|
|
||||||
def perform_threaded(self):
|
def perform_threaded(self):
|
||||||
self.background_thread = threading.Thread(target=self.perform_transfer)
|
self.background_thread = threading.Thread(target=self.perform_transfer)
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import wx
|
import wx
|
||||||
from mysc import event
|
|
||||||
from utils import *
|
from utils import *
|
||||||
|
import widgetUtils
|
||||||
|
|
||||||
__all__ = ['TransferDialog', 'DownloadDialog', 'UploadDialog']
|
class TransferDialog(widgetUtils.BaseDialog):
|
||||||
|
|
||||||
class TransferDialog(wx.Dialog):
|
|
||||||
|
|
||||||
def __init__(self, filename, *args, **kwargs):
|
def __init__(self, filename, *args, **kwargs):
|
||||||
super(TransferDialog, self).__init__(*args, **kwargs)
|
super(TransferDialog, self).__init__(parent=None, id=wx.NewId(), *args, **kwargs)
|
||||||
self.pane = wx.Panel(self)
|
self.pane = wx.Panel(self)
|
||||||
self.progress_bar = wx.Gauge(parent=self.pane)
|
self.progress_bar = wx.Gauge(parent=self.pane)
|
||||||
fileBox = wx.BoxSizer(wx.HORIZONTAL)
|
fileBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
@ -37,7 +35,7 @@ class TransferDialog(wx.Dialog):
|
|||||||
self.eta = wx.TextCtrl(self.pane, -1, style=wx.TE_READONLY|wx.TE_MULTILINE, value="Unknown", size=(200, 100))
|
self.eta = wx.TextCtrl(self.pane, -1, style=wx.TE_READONLY|wx.TE_MULTILINE, value="Unknown", size=(200, 100))
|
||||||
etaBox.Add(etaLabel)
|
etaBox.Add(etaLabel)
|
||||||
etaBox.Add(self.eta)
|
etaBox.Add(self.eta)
|
||||||
# self.create_buttons()
|
self.create_buttons()
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
sizer.Add(fileBox)
|
sizer.Add(fileBox)
|
||||||
sizer.Add(currentAmountBox)
|
sizer.Add(currentAmountBox)
|
||||||
@ -46,10 +44,8 @@ class TransferDialog(wx.Dialog):
|
|||||||
sizer.Add(etaBox)
|
sizer.Add(etaBox)
|
||||||
sizer.Add(self.progress_bar)
|
sizer.Add(self.progress_bar)
|
||||||
self.pane.SetSizerAndFit(sizer)
|
self.pane.SetSizerAndFit(sizer)
|
||||||
self.Bind(event.MyEVT_OBJECT, self.update)
|
|
||||||
|
|
||||||
def update(self, ev):
|
def update(self, data):
|
||||||
data = ev.GetItem()
|
|
||||||
wx.CallAfter(self.progress_bar.SetValue, data["percent"])
|
wx.CallAfter(self.progress_bar.SetValue, data["percent"])
|
||||||
wx.CallAfter(self.current_amount.SetValue, '%s (%d%%)' % (convert_bytes(data["current"]), data["percent"]))
|
wx.CallAfter(self.current_amount.SetValue, '%s (%d%%)' % (convert_bytes(data["current"]), data["percent"]))
|
||||||
wx.CallAfter(self.total_size.SetValue, convert_bytes(data["total"]))
|
wx.CallAfter(self.total_size.SetValue, convert_bytes(data["total"]))
|
||||||
@ -59,7 +55,12 @@ class TransferDialog(wx.Dialog):
|
|||||||
|
|
||||||
def create_buttons(self):
|
def create_buttons(self):
|
||||||
self.cancel_button = wx.Button(parent=self.pane, id=wx.ID_CANCEL)
|
self.cancel_button = wx.Button(parent=self.pane, id=wx.ID_CANCEL)
|
||||||
self.cancel_button.Bind(wx.EVT_BUTTON, self.on_cancel)
|
|
||||||
|
def get_response(self):
|
||||||
|
self.Show()
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.Destroy()
|
||||||
|
|
||||||
class UploadDialog(TransferDialog):
|
class UploadDialog(TransferDialog):
|
||||||
|
|
64
src/extra/AudioUploader/wx_ui.py
Normal file
64
src/extra/AudioUploader/wx_ui.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
############################################################
|
||||||
|
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
import wx
|
||||||
|
import widgetUtils
|
||||||
|
import output
|
||||||
|
|
||||||
|
class audioDialog(widgetUtils.BaseDialog):
|
||||||
|
def __init__(self, services):
|
||||||
|
super(audioDialog, self).__init__(None, -1, _(u"Attach audio"))
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
self.play = wx.Button(panel, -1, _(u"Play"))
|
||||||
|
self.play.Disable()
|
||||||
|
self.pause = wx.Button(panel, -1, _(u"Pause"))
|
||||||
|
self.pause.Disable()
|
||||||
|
self.record = wx.Button(panel, -1, _(u"Record"))
|
||||||
|
self.record.SetFocus()
|
||||||
|
self.attach_exists = wx.Button(panel, -1, _(u"Add an existing file"))
|
||||||
|
self.discard = wx.Button(panel, -1, _(u"Discard"))
|
||||||
|
self.discard.Disable()
|
||||||
|
label = wx.StaticText(panel, -1, _(u"Upload to"))
|
||||||
|
self.services = wx.ComboBox(panel, -1, choices=services, value=services[0], style=wx.CB_READONLY)
|
||||||
|
servicesBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
servicesBox.Add(label)
|
||||||
|
servicesBox.Add(self.services)
|
||||||
|
self.attach = wx.Button(panel, wx.ID_OK, _(u"Attach"))
|
||||||
|
self.attach.Disable()
|
||||||
|
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
||||||
|
sizer.Add(self.play)
|
||||||
|
sizer.Add(self.pause)
|
||||||
|
sizer.Add(self.record)
|
||||||
|
sizer.Add(self.attach_exists)
|
||||||
|
sizer.Add(self.discard)
|
||||||
|
sizer.Add(self.attach)
|
||||||
|
|
||||||
|
def enable_control(self, control):
|
||||||
|
if hasattr(self, control):
|
||||||
|
getattr(self, control).Enable()
|
||||||
|
|
||||||
|
def disable_control(self, control):
|
||||||
|
if hasattr(self, control):
|
||||||
|
getattr(self, control).Disable()
|
||||||
|
|
||||||
|
def get_file(self):
|
||||||
|
openFileDialog = wx.FileDialog(self, _(u"Select the audio file to be uploaded"), "", "", _("Audio Files (*.mp3, *.ogg, *.wav)|*.mp3; *.ogg; *.wav"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||||
|
if openFileDialog.ShowModal() == wx.ID_CANCEL:
|
||||||
|
return False
|
||||||
|
return openFileDialog.GetPath()
|
@ -1 +1 @@
|
|||||||
import gui
|
from soundsTutorial import *
|
@ -1,59 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import wx
|
|
||||||
import config
|
|
||||||
import os
|
|
||||||
import paths
|
|
||||||
import sound
|
|
||||||
|
|
||||||
class soundsTutorial(wx.Dialog):
|
|
||||||
def __init__(self):
|
|
||||||
self.actions = [
|
|
||||||
_(u"The tweet may contain a playable audio"),
|
|
||||||
_(u"A timeline has been created"),
|
|
||||||
_(u"A timeline has been deleted"),
|
|
||||||
_(u"You've received a direct message"),
|
|
||||||
_(u"You've sent a direct message"),
|
|
||||||
_(u"A bug has happened"),
|
|
||||||
_(u"You've added a tweet to your favourites"),
|
|
||||||
_(u"Someone's favourites have been updated"),
|
|
||||||
_(u"There are no more tweets to read"),
|
|
||||||
_(u"A list has a new tweet"),
|
|
||||||
_(u"You can't add any more characters on the tweet"),
|
|
||||||
_(u"You've been mentioned "),
|
|
||||||
_(u"A new event has happened"),
|
|
||||||
_(u"TW Blue is ready "),
|
|
||||||
_(u"You've replied"),
|
|
||||||
_(u"You've retweeted"),
|
|
||||||
_(u"A search has been updated"),
|
|
||||||
_(u"There's a new tweet in the main buffer"),
|
|
||||||
_(u"You've sent a tweet"),
|
|
||||||
_(u"There's a new tweet in a timeline"),
|
|
||||||
_(u"You have a new follower"),
|
|
||||||
_(u"You've turned the volume up or down")]
|
|
||||||
self.files = os.listdir(paths.sound_path("default"))
|
|
||||||
super(soundsTutorial, self).__init__(None, -1)
|
|
||||||
if len(self.actions) > len(self.files):
|
|
||||||
wx.MessageDialog(None, _(u"It seems as though the currently used sound pack needs an update. %i fails are still be required to use this function. Make sure to obtain the needed lacking sounds or to contact with the sound pack developer.") % (len(self.actions) - len(self.files)), _(u"Error"), wx.ICON_ERROR).ShowModal()
|
|
||||||
self.Destroy()
|
|
||||||
self.SetTitle(_(u"Sounds tutorial"))
|
|
||||||
panel = wx.Panel(self)
|
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
label = wx.StaticText(panel, -1, _(u"Press enter to listen to the sound for the selected event"))
|
|
||||||
self.items = wx.ListBox(panel, 1, choices=self.actions, style=wx.LB_SINGLE)
|
|
||||||
self.items.SetSelection(0)
|
|
||||||
listBox = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
listBox.Add(label)
|
|
||||||
listBox.Add(self.items)
|
|
||||||
play = wx.Button(panel, 1, (u"Play"))
|
|
||||||
play.SetDefault()
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.onPlay, play)
|
|
||||||
close = wx.Button(panel, wx.ID_CANCEL)
|
|
||||||
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
btnBox.Add(play)
|
|
||||||
btnBox.Add(close)
|
|
||||||
sizer.Add(listBox)
|
|
||||||
sizer.Add(btnBox)
|
|
||||||
panel.SetSizer(sizer)
|
|
||||||
|
|
||||||
def onPlay(self, ev):
|
|
||||||
sound.player.play(self.files[self.items.GetSelection()])
|
|
22
src/extra/SoundsTutorial/soundsTutorial.py
Normal file
22
src/extra/SoundsTutorial/soundsTutorial.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import widgetUtils
|
||||||
|
import config
|
||||||
|
import os
|
||||||
|
import paths
|
||||||
|
import sound
|
||||||
|
import wx_ui
|
||||||
|
import soundsTutorial_constants
|
||||||
|
|
||||||
|
class soundsTutorial(object):
|
||||||
|
def __init__(self):
|
||||||
|
super(soundsTutorial, self).__init__()
|
||||||
|
self.actions = []
|
||||||
|
[self.actions.append(i[1]) for i in soundsTutorial_constants.actions]
|
||||||
|
self.files = []
|
||||||
|
[self.files.append(i[0]) for i in soundsTutorial_constants.actions]
|
||||||
|
self.dialog = wx_ui.soundsTutorialDialog(self.actions)
|
||||||
|
widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play)
|
||||||
|
self.dialog.get_response()
|
||||||
|
|
||||||
|
def on_play(self, *args, **kwargs):
|
||||||
|
sound.player.play(self.files[self.dialog.items.GetSelection()]+".ogg")
|
23
src/extra/SoundsTutorial/soundsTutorial_constants.py
Normal file
23
src/extra/SoundsTutorial/soundsTutorial_constants.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
actions = [ ("audio", _(u"The tweet may contain a playable audio")),
|
||||||
|
("create_timeline", _(u"A timeline has been created")),
|
||||||
|
("delete_timeline", _(u"A timeline has been deleted")),
|
||||||
|
("dm_received", _(u"You've received a direct message")),
|
||||||
|
("dm_sent", _(u"You've sent a direct message")),
|
||||||
|
("error", _(u"A bug has happened")),
|
||||||
|
("favourite", _(u"You've added a tweet to your favourites")),
|
||||||
|
("favourites_timeline_updated", _(u"Someone's favourites have been updated")),
|
||||||
|
("limit", _(u"There are no more tweets to read")),
|
||||||
|
("list_tweet", _(u"A list has a new tweet")),
|
||||||
|
("max_length", _(u"You can't add any more characters on the tweet")),
|
||||||
|
("mention_received", _(u"You've been mentioned ")),
|
||||||
|
("new_event", _(u"A new event has happened")),
|
||||||
|
("ready", _(u"TW Blue is ready ")),
|
||||||
|
("reply_send", _(u"You've replied")),
|
||||||
|
("retweet_send", _(u"You've retweeted")),
|
||||||
|
("search_updated", _(u"A search has been updated")),
|
||||||
|
("tweet_received", _(u"There's a new tweet in the main buffer")),
|
||||||
|
("tweet_send", _(u"You've sent a tweet")),
|
||||||
|
("tweet_timeline", _(u"There's a new tweet in a timeline")),
|
||||||
|
("update_followers", _(u"You have a new follower")),
|
||||||
|
("volume_changed", _(u"You've turned the volume up or down"))]
|
25
src/extra/SoundsTutorial/wx_ui.py
Normal file
25
src/extra/SoundsTutorial/wx_ui.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import wx
|
||||||
|
import widgetUtils
|
||||||
|
|
||||||
|
class soundsTutorialDialog(widgetUtils.BaseDialog):
|
||||||
|
def __init__(self, actions):
|
||||||
|
super(soundsTutorialDialog, self).__init__(None, -1)
|
||||||
|
self.SetTitle(_(u"Sounds tutorial"))
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
label = wx.StaticText(panel, -1, _(u"Press enter to listen to the sound for the selected event"))
|
||||||
|
self.items = wx.ListBox(panel, 1, choices=actions, style=wx.LB_SINGLE)
|
||||||
|
self.items.SetSelection(0)
|
||||||
|
listBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
listBox.Add(label)
|
||||||
|
listBox.Add(self.items)
|
||||||
|
self.play = wx.Button(panel, 1, (u"Play"))
|
||||||
|
self.play.SetDefault()
|
||||||
|
close = wx.Button(panel, wx.ID_CANCEL)
|
||||||
|
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
btnBox.Add(self.play)
|
||||||
|
btnBox.Add(close)
|
||||||
|
sizer.Add(listBox)
|
||||||
|
sizer.Add(btnBox)
|
||||||
|
panel.SetSizer(sizer)
|
@ -1,8 +1,8 @@
|
|||||||
import wx
|
import wx
|
||||||
|
|
||||||
class BaseWXDialog(wx.Dialog):
|
class BaseDialog(wx.Dialog):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BaseWXDialog, self).__init__(*args, **kwargs)
|
super(BaseDialog, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_response(self):
|
def get_response(self):
|
||||||
return self.ShowModal()
|
return self.ShowModal()
|
||||||
@ -13,4 +13,13 @@ class BaseWXDialog(wx.Dialog):
|
|||||||
if hasattr(control, "GetValue"): return getattr(control, "GetValue")()
|
if hasattr(control, "GetValue"): return getattr(control, "GetValue")()
|
||||||
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
|
||||||
|
|
||||||
|
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
|
else: return 0
|
@ -20,7 +20,7 @@ class mainFrame(wx.Frame):
|
|||||||
lists = app.Append(wx.NewId(), _(u"&Lists manager"))
|
lists = app.Append(wx.NewId(), _(u"&Lists manager"))
|
||||||
# self.view.Bind(wx.EVT_MENU, self.list_manager, lists)
|
# self.view.Bind(wx.EVT_MENU, self.list_manager, lists)
|
||||||
sounds_tutorial = app.Append(wx.NewId(), _(u"Sounds &tutorial"))
|
sounds_tutorial = app.Append(wx.NewId(), _(u"Sounds &tutorial"))
|
||||||
# self.view.Bind(wx.EVT_MENU, self.learn_sounds, sounds_tutorial)
|
self.Bind(wx.EVT_MENU, self.controller.learn_sounds, sounds_tutorial)
|
||||||
keystroke_editor = app.Append(wx.NewId(), _(u"&Edit keystrokes"))
|
keystroke_editor = app.Append(wx.NewId(), _(u"&Edit keystrokes"))
|
||||||
self.Bind(wx.EVT_MENU, self.controller.edit_keystrokes, keystroke_editor)
|
self.Bind(wx.EVT_MENU, self.controller.edit_keystrokes, keystroke_editor)
|
||||||
prefs = app.Append(wx.ID_PREFERENCES, _(u"&Preferences"))
|
prefs = app.Append(wx.ID_PREFERENCES, _(u"&Preferences"))
|
||||||
|
Loading…
Reference in New Issue
Block a user