mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Added extras panel in account settings, added OCR Language selection for #107
This commit is contained in:
parent
1061967adc
commit
03415f6b24
@ -11,6 +11,7 @@ import application
|
|||||||
from wxUI.dialogs import configuration
|
from wxUI.dialogs import configuration
|
||||||
from wxUI import commonMessageDialogs
|
from wxUI import commonMessageDialogs
|
||||||
from extra.autocompletionUsers import settings
|
from extra.autocompletionUsers import settings
|
||||||
|
from extra.ocr import OCRSpace
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
import logging
|
import logging
|
||||||
import config_utils
|
import config_utils
|
||||||
@ -164,7 +165,7 @@ class accountSettingsController(globalSettingsController):
|
|||||||
self.dialog.set_value("sound", "indicate_audio", self.config["sound"]["indicate_audio"])
|
self.dialog.set_value("sound", "indicate_audio", self.config["sound"]["indicate_audio"])
|
||||||
self.dialog.set_value("sound", "indicate_geo", self.config["sound"]["indicate_geo"])
|
self.dialog.set_value("sound", "indicate_geo", self.config["sound"]["indicate_geo"])
|
||||||
self.dialog.set_value("sound", "indicate_img", self.config["sound"]["indicate_img"])
|
self.dialog.set_value("sound", "indicate_img", self.config["sound"]["indicate_img"])
|
||||||
self.dialog.create_extras()
|
self.dialog.create_extras(OCRSpace.translatable_langs)
|
||||||
self.dialog.realize()
|
self.dialog.realize()
|
||||||
self.dialog.set_title(_(u"Account settings for %s") % (self.user,))
|
self.dialog.set_title(_(u"Account settings for %s") % (self.user,))
|
||||||
self.response = self.dialog.get_response()
|
self.response = self.dialog.get_response()
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
""" original module taken and modified from https://github.com/ctoth/cloudOCR"""
|
""" original module taken and modified from https://github.com/ctoth/cloudOCR"""
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
translatable_langs = [_(u"Detect automatically"), _(u"Danish"), _(u"Dutch"), _(u"English"), _(u"Finnish"), _(u"French"), _(u"German"), _(u"Hungarian"), _(u"Korean"), _(u"Italian"), _(u"Japanese"), _(u"Polish"), _(u"Portuguese"), _(u"Russian"), _(u"Spanish"), _(u"Turkish")]
|
||||||
|
short_langs = ["", "da", "du", "en", "fi", "fr", "de", "hu", "ko", "it", "ja", "pl", "pt", "ru", "es", "tr"]
|
||||||
|
OcrLangs = ["", "dan", "dut", "eng", "fin", "fre", "ger", "hun", "kor", "ita", "jpn", "pol", "por", "rus", "spa", "tur"]
|
||||||
|
|
||||||
class APIError(Exception):
|
class APIError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -294,38 +294,19 @@ class sound(wx.Panel):
|
|||||||
def get(self, control):
|
def get(self, control):
|
||||||
return getattr(self, control).GetStringSelection()
|
return getattr(self, control).GetStringSelection()
|
||||||
|
|
||||||
class servicesPanel(wx.Panel):
|
class extrasPanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent, ocr_languages=[], translation_languages=[]):
|
||||||
super(servicesPanel, self).__init__(parent)
|
super(extrasPanel, self).__init__(parent)
|
||||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
apiKeyLabel = wx.StaticText(self, -1, _(u"If you have a SndUp account, enter your API Key here. If your API Key is invalid, {0} will fail to upload. If there is no API Key here, {0} will upload annonymously.").format(application.name,))
|
OCRBox = wx.StaticBox(self, label=_(u"Language for OCR"))
|
||||||
self.apiKey = wx.TextCtrl(self, -1)
|
self.ocr_lang = wx.ListBox(self, -1, choices=ocr_languages)
|
||||||
dc = wx.WindowDC(self.apiKey)
|
self.ocr_lang.SetSize(self.ocr_lang.GetBestSize())
|
||||||
dc.SetFont(self.apiKey.GetFont())
|
ocrLanguageSizer = wx.StaticBoxSizer(OCRBox, wx.HORIZONTAL)
|
||||||
self.apiKey.SetSize(dc.GetTextExtent("0"*100))
|
ocrLanguageSizer.Add(self.ocr_lang, 0, wx.ALL, 5)
|
||||||
apiKeyBox = wx.BoxSizer(wx.HORIZONTAL)
|
mainSizer.Add(ocrLanguageSizer, 0, wx.ALL, 5)
|
||||||
apiKeyBox.Add(apiKeyLabel, 0, wx.ALL, 5)
|
|
||||||
apiKeyBox.Add(self.apiKey, 0, wx.ALL, 5)
|
|
||||||
mainSizer.Add(apiKeyBox, 0, wx.ALL, 5)
|
|
||||||
# self.pocketBtn = wx.Button(self, -1)
|
|
||||||
# mainSizer.Add(self.pocketBtn, 0, wx.ALL, 5)
|
|
||||||
self.SetSizer(mainSizer)
|
self.SetSizer(mainSizer)
|
||||||
|
|
||||||
def set_pocket(self, active=True):
|
|
||||||
if active == True:
|
|
||||||
self.pocketBtn.SetLabel(_(u"Disconnect your Pocket account"))
|
|
||||||
else:
|
|
||||||
self.pocketBtn.SetLabel(_(u"Connect your Pocket account"))
|
|
||||||
|
|
||||||
def show_pocket_dialog(self):
|
|
||||||
return wx.MessageDialog(self, _(u"The authorization request will be opened in your browser. You only need to do this once. Do you want to continue?"), _(u"Pocket Authorization"), wx.YES_NO).ShowModal()
|
|
||||||
|
|
||||||
def show_pocket_authorization_error(self):
|
|
||||||
wx.MessageDialog(self, _(u"Error during authorization. Try again later."), _(u"Error!"), wx.ICON_ERROR).ShowModal()
|
|
||||||
|
|
||||||
def get_pocket_status(self):
|
|
||||||
return self.pocketBtn.GetLabel()
|
|
||||||
|
|
||||||
class configurationDialog(baseDialog.BaseWXDialog):
|
class configurationDialog(baseDialog.BaseWXDialog):
|
||||||
def set_title(self, title):
|
def set_title(self, title):
|
||||||
self.SetTitle(title)
|
self.SetTitle(title)
|
||||||
@ -363,9 +344,9 @@ class configurationDialog(baseDialog.BaseWXDialog):
|
|||||||
self.sound = sound(self.notebook, output_devices, input_devices, soundpacks)
|
self.sound = sound(self.notebook, output_devices, input_devices, soundpacks)
|
||||||
self.notebook.AddPage(self.sound, _(u"Sound"))
|
self.notebook.AddPage(self.sound, _(u"Sound"))
|
||||||
|
|
||||||
def create_services(self):
|
def create_extras(self, ocr_languages=[], translator_languages=[]):
|
||||||
self.services = servicesPanel(self.notebook)
|
self.extras = extrasPanel(self.notebook, ocr_languages, translator_languages)
|
||||||
self.notebook.AddPage(self.services, _(u"Services"))
|
self.notebook.AddPage(self.extras, _(u"Extras"))
|
||||||
|
|
||||||
def realize(self):
|
def realize(self):
|
||||||
self.sizer.Add(self.notebook, 0, wx.ALL, 5)
|
self.sizer.Add(self.notebook, 0, wx.ALL, 5)
|
||||||
|
Loading…
Reference in New Issue
Block a user