本文整理匯總了Python中main_window.MainWindow.update方法的典型用法代碼示例。如果您正苦於以下問題:Python MainWindow.update方法的具體用法?Python MainWindow.update怎麽用?Python MainWindow.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main_window.MainWindow
的用法示例。
在下文中一共展示了MainWindow.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DomorIndicator
# 需要導入模塊: from main_window import MainWindow [as 別名]
# 或者: from main_window.MainWindow import update [as 別名]
class DomorIndicator(object):
def __init__(self):
# build UI from glade file
builder = Gtk.Builder()
#builder.add_from_file(to_abs_path(PoResources.UI_TRAY))
builder.add_from_file(to_abs_path(PoResources.UI_TRAY))
builder.connect_signals(self)
style.setStyle()
# get some common used object
self.builder = builder
self.menu = builder.get_object('tray_menu')
self.lb_clock = builder.get_object('mni_clock')
self.lb_counter = builder.get_object('mni_archive_count')
APPIND_SUPPORT = 1
try:
from gi.repository import AppIndicator3
except:
APPIND_SUPPORT = 0
if APPIND_SUPPORT == 1:
self.ind = AppIndicator3.Indicator.new_with_path("domor-indicator", 'app_icon_64',
AppIndicator3.IndicatorCategory.APPLICATION_STATUS,
to_abs_path('img'))
self.ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
self.ind.set_menu(self.menu)
else:
self.myStatusIcon = Gtk.StatusIcon()
self.myStatusIcon.set_from_file(
to_abs_path(PoResources.ICON_APP_64))
self.myStatusIcon.connect(
'popup-menu', self.right_click_event_statusicon)
# 6 load config
self.settings = settings = Settings()
settings.load_config()
# 7 init class state
self.btn_state = State.STOP
self.state = State.IDLE
self.time = settings.short_work_time
self.work_time = 0
self.count = 0
# create main screen
self.main_window = MainWindow(self.on_mni_start_activate)
self.main_window.update(self.state, self.btn_state)
# create rest screen
self.break_screen = BreakScreen(self.on_skip_break)
self.reset()
# register timer callback
GObject.timeout_add_seconds(1, self.count_down)
def reset(self):
'''
Reset to default state
:return:
'''
self.state = State.IDLE
self.time = self.settings.short_work_time
self.btn_state = State.STOP
self._update_item(
'mni_start', get_resource(PoResources.ICON_START), 'Start')
self._update_time()
# hide break screen if showing
self.break_screen.hide()
if self.main_window:
self.main_window.update(self.state, self.btn_state)
def on_skip_break(self):
if self.state == State.BREAK:
# if time is counting and in break period and user click PAUSE button
# reset timer and button state
self.reset()
def _update_item(self, item_id, img_path, label=None):
"""
Update image for button
:param button_id: id of button which is updated
:param img_path: path to image
:return: None
"""
try:
item = self.builder.get_object(item_id)
img = Gtk.Image.new_from_file(img_path)
item.set_image(img)
if label:
item.set_label(label)
except Exception as e:
print item_id
print e.message
#.........這裏部分代碼省略.........