本文整理汇总了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
#.........这里部分代码省略.........