Moved profile displayer to MVP pattern. User info is collected in a thread

This commit is contained in:
2019-01-06 19:41:00 -06:00
parent 0f68d2d0fc
commit 73d2d4a95d
10 changed files with 160 additions and 158 deletions

View File

@@ -1,2 +1,3 @@
from . audioRecorder import *
from .configuration import *
from .configuration import *
from .profiles import *

View File

@@ -11,12 +11,17 @@ class baseInteractor(object):
pub.subscribe(self.enable_control, "{modulename}_enable_control".format(modulename=modulename))
pub.subscribe(self.set_label, "{modulename}_set_label".format(modulename=modulename))
pub.subscribe(self.focus_control, "{modulename}_focus_control".format(modulename=modulename))
pub.subscribe(self.set_title, "{modulename}_set_title".format(modulename=modulename))
def uninstall(self):
pub.unsubscribe(self.disable_control, "{modulename}_disable_control".format(modulename=self.modulename))
pub.unsubscribe(self.enable_control, "{modulename}_enable_control".format(modulename=self.modulename))
pub.unsubscribe(self.set_label, "{modulename}_set_label".format(modulename=self.modulename))
pub.unsubscribe(self.focus_control, "{modulename}_focus_control".format(modulename=self.modulename))
pub.unsubscribe(self.set_title, "{modulename}_set_title".format(modulename=self.modulename))
def start(self):
self.result = self.view.get_response()
def disable_control(self, control):
self.view.disable(control)
@@ -29,3 +34,6 @@ class baseInteractor(object):
def set_label(self, control, label):
self.view.set(control, label)
def set_title(self, value):
self.view.SetTitle(value)

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import six
import wx
import widgetUtils
from pubsub import pub
from views.dialogs import urlList
from . import base
class userProfileInteractor(base.baseInteractor):
def enable_control(self, tab, control):
if not hasattr(self.view, tab):
raise AttributeError("The viw does not contain the specified tab.")
tab = getattr(self.view, tab)
if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.")
getattr(tab, control).Enable(True)
def set(self, tab, control, value):
if not hasattr(self.view, tab):
raise AttributeError("The viw does not contain the specified tab.")
tab = getattr(self.view, tab)
if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.")
control = getattr(tab, control)
control.SetValue(value)
def set_label(self, tab, control, value):
if not hasattr(self.view, tab):
raise AttributeError("The viw does not contain the specified tab.")
tab = getattr(self.view, tab)
if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.")
control = getattr(tab, control)
control.SetLabel(value)
def load_image(self, image):
image = wx.Image(stream=six.BytesIO(image.content))
try:
self.view.image.SetBitmap(wx.Bitmap(image))
except ValueError:
return
self.view.panel.Layout()
def install(self, *args, **kwargs):
super(userProfileInteractor, self).install(*args, **kwargs)
pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.load_image, self.modulename+"_load_image")
self.view.create_controls("main_info")
self.view.realice()
widgetUtils.connect_event(self.view.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.on_visit_website)
def uninstall(self):
super(userProfileInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.load_image, self.modulename+"_load_image")
def on_visit_website(self, *args, **kwargs):
urls = self.presenter.get_urls()
if len(urls) == 1:
self.presenter.visit_url(urls[0])
else:
dialog = urlList.urlList()
dialog.populate_list(urls)
if dialog.get_response() != widgetUtils.OK:
return
selected_url = urls[dialog.get_item()]
self.presenter.visit_url(selected_url)