Example #1
0
 def plugin_widget(self):
     self.tray_icon.set_tooltip_text(
         "%s %s" % (time.strftime("%Y-%m-%d"),
                    self.WEEK[int(time.strftime("%w")) - 1]))
     align = self.__setup_align()
     box = gtk.VBox(spacing=5)
     calendar_align = self.__setup_align()
     calendar = deepin_lunar.new()
     self.calendar = deepin_lunar.new()
     if MAIN_LANG == "en_US":
         self.calendar = dltk_calendar.new()
     calendar.mark_day(time.localtime().tm_mday)
     calendar.set_day_padding(0)
     calendar.get_handle().set_property("show-details", False)
     if len(locale.getdefaultlocale([
             'LANGUAGE'
     ])) and locale.getdefaultlocale(['LANGUAGE'])[0] is not None:
         if locale.getdefaultlocale(['LANGUAGE'])[0].find("zh_CN") != 0:
             self.width = 230
     else:
         self.width = 230
     calendar.get_handle().set_size_request(self.width, 172)
     calendar_align.add(calendar.get_handle())
     select_align = self.__setup_align()
     select_button = SelectButton(_("Change date and time settings"),
                                  font_size=10,
                                  ali_padding=5)
     select_button.set_size_request(self.width, 25)
     select_align.add(select_button)
     select_button.connect("clicked", self.__on_day_selected)
     box.pack_start(calendar_align, False, False)
     box.pack_start(select_align, False, False)
     align.add(box)
     return align
 def plugin_widget(self):
     self.tray_icon.set_tooltip_text("%s %s" % (time.strftime("%Y-%m-%d"),   
                                                self.WEEK[int(time.strftime("%w")) - 1]))
     align = self.__setup_align()
     box = gtk.VBox(spacing = 5)
     calendar_align = self.__setup_align()
     calendar = deepin_lunar.new()
     self.calendar = deepin_lunar.new()                                      
     if MAIN_LANG == "en_US":
         self.calendar = dltk_calendar.new()
     calendar.mark_day(time.localtime().tm_mday)
     calendar.set_day_padding(0)
     calendar.get_handle().set_property("show-details", False)
     if len(locale.getdefaultlocale(['LANGUAGE'])) and locale.getdefaultlocale(['LANGUAGE'])[0] is not None:
         if locale.getdefaultlocale(['LANGUAGE'])[0].find("zh_CN") != 0:
             self.width = 230
     else:
         self.width = 230
     calendar.get_handle().set_size_request(self.width, 172)
     calendar_align.add(calendar.get_handle())
     select_align = self.__setup_align()
     select_button = SelectButton(_("Change date and time settings"), 
                                  font_size = 10, 
                                  ali_padding = 5)
     select_button.set_size_request(self.width, 25)
     select_align.add(select_button)
     select_button.connect("clicked", self.__on_day_selected)
     box.pack_start(calendar_align, False, False)
     box.pack_start(select_align, False, False)
     align.add(box)
     return align
    def __init__(self):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)

        self.__toggle_id = None
        self.__time_id = None

        self.datetime_settings = deepin_gsettings.new("com.deepin.dde.datetime")

        self.__deepin_dt = DeepinDateTime()
        self.current_tz_gmtoff = self.__deepin_dt.get_gmtoff()

        self.timezone_items = []
        self.timezone_items.append((_("(UTC-11:00)Samoa"), -11))
        self.timezone_items.append((_("(UTC-10:00)Hawaii"), -10))
        self.timezone_items.append((_("(UTC-09:00)Alaska"), -9))
        self.timezone_items.append((_("(UTC-08:00)Lower California"), -8))
        self.timezone_items.append((_("(UTC-07:00)Arizona, Llamas, Mazatlan, Chihuahua"), -7))
        self.timezone_items.append((_("(UTC-06:00)Saskatchewan, Mexico City, Monterrey"), -6))
        self.timezone_items.append((_("(UTC-05:00)Indiana, Bogota, Lima, Quito"), -5))
        self.timezone_items.append((_("(UTC-04:00)San Diego, Georgetown, San Juan"), -4))
        self.timezone_items.append((_("(UTC-03:00)Greenland, Brasilia, Fortaleza"), -3))
        self.timezone_items.append((_("(UTC-02:00)Mid-Atlantic"), -2))
        self.timezone_items.append((_("(UTC-01:00)Cape Verde Islands, Azores"), -1))
        self.timezone_items.append((_("(UTC)London, Dublin, Edinburgh, Lisbon, Casablanca"), 0))
        self.timezone_items.append((_("(UTC+01:00)Paris, Amsterdam, Berlin, Rome, Vienna"), 1))
        self.timezone_items.append((_("(UTC+02:00)Cairo, Athens, Istanbul, Jerusalem"), 2))
        self.timezone_items.append((_("(UTC+03:00)Moscow, St. Petersburg, Baghdad"), 3))
        self.timezone_items.append((_("(UTC+04:00)Port Louis, Abu Dhabi, Muscat, Yerevan"), 4))
        self.timezone_items.append((_("(UTC+05:00)Islamabad, Karachi, Tashkent"), 5))
        self.timezone_items.append((_("(UTC+06:00)Dhaka, Novosibirsk"), 6))
        self.timezone_items.append((_("(UTC+07:00)Bangkok, Hanoi, Jakarta"), 7))
        self.timezone_items.append((_("(UTC+08:00)Beijing, Chongqing, HongKong, Taipei, Urumqi"), 8))
        self.timezone_items.append((_("(UTC+09:00)Osaka, Sapporo, Tokyo, Seoul"), 9))
        self.timezone_items.append((_("(UTC+10:00)Guam, Canberra, Melbourne, Sydney"), 10))
        self.timezone_items.append((_("(UTC+11:00)Magadan, Solomon Islands"), 11))
        self.timezone_items.append((_("(UTC+12:00)New Zealand, Kiribati"), 12))
        self.is_24hour = self.datetime_settings.get_boolean("is-24hour")
        '''
        left align
        '''
        self.left_align = self.__setup_align(
            padding_top = TEXT_WINDOW_TOP_PADDING, 
            padding_left = TEXT_WINDOW_LEFT_PADDING)
        '''
        left box
        '''
        self.left_box = gtk.VBox()
        '''
        calendar title
        '''
        self.calendar_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/calendar.png"), _("Calendar"))
        '''
        current date
        '''
        self.cur_date_align = self.__setup_align()
        self.cur_date_label = self.__setup_label(
            _("Current Date: %d-%d-%d") % (time.localtime().tm_year, 
                                           time.localtime().tm_mon, 
                                           time.localtime().tm_mday), 
            190)
        self.cur_date_align.add(self.cur_date_label)
        '''
        calendar widget
        '''
        self.calendar_align = self.__setup_align(padding_top = BETWEEN_SPACING, 
            padding_bottom = 10)
        self.calendar = deepin_lunar.new()
        if MAIN_LANG == "en_US":
            self.calendar = dltk_calendar.new()
        self.calendar.mark_day(time.localtime().tm_mday)
        self.calendar.get_handle().set_size_request(300, 280)
        self.calendar.get_handle().connect("day-selected", self.__on_day_selected, self.calendar)
        self.calendar_align.add(self.calendar.get_handle())
        self.change_date_box = gtk.HBox(spacing = 5)
        self.change_date_box.set_size_request(300, -1)
        self.change_date_align = self.__setup_align()
        self.change_date_button = Button(_("Change Date"))
        self.change_date_button.connect("button-press-event", self.__on_change_date)
        self.change_date_align.add(self.change_date_button)
        self.edit_date_align = self.__setup_align()
        self.edit_date_box = gtk.HBox(spacing = 5)
        self.cancel_date_button = Button(_("Cancel"))
        self.cancel_date_button.connect("button-press-event", self.__on_cancel_change_date)
        self.confirm_date_button = Button(_("Confirm"))
        self.confirm_date_button.connect("button-press-event", self.__on_confirm_change_date)
        self.__widget_pack_start(self.edit_date_box, 
            [self.cancel_date_button, self.confirm_date_button])
        self.edit_date_align.add(self.edit_date_box)

        self.change_date_box.pack_end(self.change_date_align, False, False)
        '''
        left box && align
        '''
        self.__widget_pack_start(self.left_box, 
            [self.calendar_title_align, 
             self.cur_date_align, 
             self.calendar_align, 
             self.change_date_box])
        self.left_align.add(self.left_box)
        '''
        right align
        '''
        self.right_align = self.__setup_align(
            padding_top = TEXT_WINDOW_TOP_PADDING, padding_left = TEXT_WINDOW_LEFT_PADDING)
        '''
        right box
        '''
        self.right_box = gtk.VBox()
        '''
        time title
        '''
        self.time_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/time.png"), _("Time"))
        '''
        current time
        '''
        self.cur_time_align = self.__setup_align()
        if self.is_24hour:
            self.cur_time_label = self.__setup_label(
                _("Current Time: %s %02d:%02d:%02d (%d Hour)") % 
                  (time.strftime('%p'), 
                   time.localtime().tm_hour, 
                   time.localtime().tm_min, 
                   time.localtime().tm_sec, 
                   24), 
                260)
        else:
            self.cur_time_label = self.__setup_label(                           
                _("Current Time: %s %02d:%02d:%02d (%d Hour)") %                
                  (time.strftime('%p'),                                         
                   time.localtime().tm_hour,                                    
                   time.localtime().tm_min,                                     
                   time.localtime().tm_sec,                                     
                   12),                                                         
                260)     

        self.cur_time_align.add(self.cur_time_label)
        '''
        DateTime widget
        '''
        self.datetime_widget_align = self.__setup_align(padding_top = BETWEEN_SPACING)
        self.datetime_widget = DateTimeHTCStyle(is_24hour = self.is_24hour)
        self.datetime_widget_align.add(self.datetime_widget)
        self.set_time_align = self.__setup_align()
        '''
        auto time get && set
        '''
        self.auto_time_align = self.__setup_align(padding_top = TEXT_WINDOW_TOP_PADDING)
        self.auto_time_box = gtk.HBox(spacing = BETWEEN_SPACING)
        self.auto_time_label = self.__setup_label(_("NTP"))
        self.auto_time_toggle = self.__setup_toggle()
        is_auto_set_time = self.datetime_settings.get_boolean("is-auto-set")
        if is_auto_set_time:
            #AutoSetTimeThread(self).start()
            self.__deepin_dt.set_using_ntp(True)
        else:
            self.__deepin_dt.set_using_ntp(False)
        self.auto_time_toggle_align = self.__setup_align(padding_top = 4)
        self.auto_time_toggle.set_active(is_auto_set_time)
        self.auto_time_toggle.connect("toggled", self.__toggled, "auto_time_toggle")
        self.auto_time_toggle_align.add(self.auto_time_toggle)
        '''
        set time
        '''
        self.set_time_spin_align = self.__setup_align(padding_left = 10, padding_top = 1)
        self.set_time_box = gtk.HBox(spacing = BETWEEN_SPACING)
        self.set_time_label = self.__setup_label(_("Set Time"), 60)
        self.set_time_spin = TimeSpinBox(is_24hour = self.is_24hour)                 
        self.set_time_spin.set_size_request(85, WIDGET_HEIGHT)                               
        self.set_time_spin.connect("value-changed", self.__time_changed)
        self.__widget_pack_start(self.set_time_box, 
            [self.set_time_label, self.set_time_spin])
        self.set_time_spin_align.add(self.set_time_box)
        self.__widget_pack_start(self.auto_time_box, 
                                 [
                                  self.auto_time_label, 
                                  self.auto_time_toggle_align, 
                                  self.set_time_spin_align]) 
        if is_auto_set_time:
            self.set_time_spin_align.set_child_visible(False)
        self.auto_time_align.add(self.auto_time_box)
        '''
        24hour display
        '''
        self.time_display_align = self.__setup_align(padding_top = BETWEEN_SPACING)
        self.time_display_box = gtk.HBox(spacing = BETWEEN_SPACING)
        self.time_display_label = self.__setup_label("24 %s" % _("Hour"))
        self.time_display_toggle_align = self.__setup_align()
        self.time_display_toggle = self.__setup_toggle()                        
        self.time_display_toggle.set_active(self.is_24hour)                          
        self.time_display_toggle.connect("toggled", self.__toggled, "time_display_toggle")
        self.time_display_toggle_align.add(self.time_display_toggle)
        self.__widget_pack_start(self.time_display_box, 
            [self.time_display_label, self.time_display_toggle_align])
        self.time_display_align.add(self.time_display_box)
        '''
        timezone
        '''
        self.timezone_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/globe-green.png"), 
            _("Time Zone"), 
            TEXT_WINDOW_TOP_PADDING)
        self.timezone_combo_align = self.__setup_align(padding_top = 6)
        self.timezone_combo = ComboBox(self.timezone_items, max_width = 340, fixed_width = 340)
        self.timezone_combo.set_select_index(self.__deepin_dt.get_gmtoff() + 11)
        self.timezone_combo.connect("item-selected", self.__combo_item_selected)
        self.timezone_combo_align.add(self.timezone_combo)

        self.__widget_pack_start(self.right_box, 
                                 [self.time_title_align, 
                                  self.cur_time_align, 
                                  self.datetime_widget_align, 
                                  self.auto_time_align, 
                                  self.time_display_align, 
                                  self.timezone_title_align, 
                                  self.timezone_combo_align])
        self.right_align.add(self.right_box)
       
        self.__widget_pack_start(self, [self.left_align, self.right_align])

        self.connect("expose-event", self.__expose)

        self.__send_message("status", ("date_time", ""))

        SecondThread(self).start()
        DateThread(self).start()
Example #4
0
import deepin_lunar
from dtk.ui.application import Application
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT

if __name__ == "__main__":
    # Init application.
    application = Application()

    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)

    # Set application icon.
    application.set_icon(os.path.join(get_current_dir(__file__), "icon.ico"))
    
    # Set application preview pixbuf.
    application.set_skin_preview(os.path.join(get_current_dir(__file__), "frame.png"))
    
    # Add titlebar.
    application.add_titlebar(
        ["theme", "max", "min", "close"], 
        os.path.join(get_current_dir(__file__), "logo.png"), 
        "TimeZone demo",
        "TimeZone demo",
        )
    
    deepin_lunar_obj = deepin_lunar.new()
    deepin_lunar_obj.mark_day(11)
    application.main_box.pack_start(deepin_lunar_obj.get_handle())

    application.run()
    def __init__(self):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)

        self.__toggle_id = None
        self.__time_id = None

        self.datetime_settings = deepin_gsettings.new(
            "com.deepin.dde.datetime")

        self.__deepin_dt = DeepinDateTime()
        self.current_tz_gmtoff = self.__deepin_dt.get_gmtoff()

        self.timezone_items = []
        self.timezone_items.append((_("(UTC-11:00)Samoa"), -11))
        self.timezone_items.append((_("(UTC-10:00)Hawaii"), -10))
        self.timezone_items.append((_("(UTC-09:00)Alaska"), -9))
        self.timezone_items.append((_("(UTC-08:00)Lower California"), -8))
        self.timezone_items.append(
            (_("(UTC-07:00)Arizona, Llamas, Mazatlan, Chihuahua"), -7))
        self.timezone_items.append(
            (_("(UTC-06:00)Saskatchewan, Mexico City, Monterrey"), -6))
        self.timezone_items.append(
            (_("(UTC-05:00)Indiana, Bogota, Lima, Quito"), -5))
        self.timezone_items.append(
            (_("(UTC-04:00)San Diego, Georgetown, San Juan"), -4))
        self.timezone_items.append(
            (_("(UTC-03:00)Greenland, Brasilia, Fortaleza"), -3))
        self.timezone_items.append((_("(UTC-02:00)Mid-Atlantic"), -2))
        self.timezone_items.append(
            (_("(UTC-01:00)Cape Verde Islands, Azores"), -1))
        self.timezone_items.append(
            (_("(UTC)London, Dublin, Edinburgh, Lisbon, Casablanca"), 0))
        self.timezone_items.append(
            (_("(UTC+01:00)Paris, Amsterdam, Berlin, Rome, Vienna"), 1))
        self.timezone_items.append(
            (_("(UTC+02:00)Cairo, Athens, Istanbul, Jerusalem"), 2))
        self.timezone_items.append(
            (_("(UTC+03:00)Moscow, St. Petersburg, Baghdad"), 3))
        self.timezone_items.append(
            (_("(UTC+04:00)Port Louis, Abu Dhabi, Muscat, Yerevan"), 4))
        self.timezone_items.append(
            (_("(UTC+05:00)Islamabad, Karachi, Tashkent"), 5))
        self.timezone_items.append((_("(UTC+06:00)Dhaka, Novosibirsk"), 6))
        self.timezone_items.append(
            (_("(UTC+07:00)Bangkok, Hanoi, Jakarta"), 7))
        self.timezone_items.append(
            (_("(UTC+08:00)Beijing, Chongqing, HongKong, Taipei, Urumqi"), 8))
        self.timezone_items.append(
            (_("(UTC+09:00)Osaka, Sapporo, Tokyo, Seoul"), 9))
        self.timezone_items.append(
            (_("(UTC+10:00)Guam, Canberra, Melbourne, Sydney"), 10))
        self.timezone_items.append(
            (_("(UTC+11:00)Magadan, Solomon Islands"), 11))
        self.timezone_items.append((_("(UTC+12:00)New Zealand, Kiribati"), 12))
        self.is_24hour = self.datetime_settings.get_boolean("is-24hour")
        '''
        left align
        '''
        self.left_align = self.__setup_align(
            padding_top=TEXT_WINDOW_TOP_PADDING,
            padding_left=TEXT_WINDOW_LEFT_PADDING)
        '''
        left box
        '''
        self.left_box = gtk.VBox()
        '''
        calendar title
        '''
        self.calendar_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/calendar.png"), _("Calendar"))
        '''
        current date
        '''
        self.cur_date_align = self.__setup_align()
        self.cur_date_label = self.__setup_label(
            _("Current Date: %d-%d-%d") %
            (time.localtime().tm_year, time.localtime().tm_mon,
             time.localtime().tm_mday), 190)
        self.cur_date_align.add(self.cur_date_label)
        '''
        calendar widget
        '''
        self.calendar_align = self.__setup_align(padding_top=BETWEEN_SPACING,
                                                 padding_bottom=10)
        self.calendar = deepin_lunar.new()
        if MAIN_LANG == "en_US":
            self.calendar = dltk_calendar.new()
        self.calendar.mark_day(time.localtime().tm_mday)
        self.calendar.get_handle().set_size_request(300, 280)
        self.calendar.get_handle().connect("day-selected",
                                           self.__on_day_selected,
                                           self.calendar)
        self.calendar_align.add(self.calendar.get_handle())
        self.change_date_box = gtk.HBox(spacing=5)
        self.change_date_box.set_size_request(300, -1)
        self.change_date_align = self.__setup_align()
        self.change_date_button = Button(_("Change Date"))
        self.change_date_button.connect("button-press-event",
                                        self.__on_change_date)
        self.change_date_align.add(self.change_date_button)
        self.edit_date_align = self.__setup_align()
        self.edit_date_box = gtk.HBox(spacing=5)
        self.cancel_date_button = Button(_("Cancel"))
        self.cancel_date_button.connect("button-press-event",
                                        self.__on_cancel_change_date)
        self.confirm_date_button = Button(_("Confirm"))
        self.confirm_date_button.connect("button-press-event",
                                         self.__on_confirm_change_date)
        self.__widget_pack_start(
            self.edit_date_box,
            [self.cancel_date_button, self.confirm_date_button])
        self.edit_date_align.add(self.edit_date_box)

        self.change_date_box.pack_end(self.change_date_align, False, False)
        '''
        left box && align
        '''
        self.__widget_pack_start(self.left_box, [
            self.calendar_title_align, self.cur_date_align,
            self.calendar_align, self.change_date_box
        ])
        self.left_align.add(self.left_box)
        '''
        right align
        '''
        self.right_align = self.__setup_align(
            padding_top=TEXT_WINDOW_TOP_PADDING,
            padding_left=TEXT_WINDOW_LEFT_PADDING)
        '''
        right box
        '''
        self.right_box = gtk.VBox()
        '''
        time title
        '''
        self.time_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/time.png"), _("Time"))
        '''
        current time
        '''
        self.cur_time_align = self.__setup_align()
        if self.is_24hour:
            self.cur_time_label = self.__setup_label(
                _("Current Time: %s %02d:%02d:%02d (%d Hour)") %
                (time.strftime('%p'), time.localtime().tm_hour,
                 time.localtime().tm_min, time.localtime().tm_sec, 24), 260)
        else:
            self.cur_time_label = self.__setup_label(
                _("Current Time: %s %02d:%02d:%02d (%d Hour)") %
                (time.strftime('%p'), time.localtime().tm_hour,
                 time.localtime().tm_min, time.localtime().tm_sec, 12), 260)

        self.cur_time_align.add(self.cur_time_label)
        '''
        DateTime widget
        '''
        self.datetime_widget_align = self.__setup_align(
            padding_top=BETWEEN_SPACING)
        self.datetime_widget = DateTimeHTCStyle(is_24hour=self.is_24hour)
        self.datetime_widget_align.add(self.datetime_widget)
        self.set_time_align = self.__setup_align()
        '''
        auto time get && set
        '''
        self.auto_time_align = self.__setup_align(
            padding_top=TEXT_WINDOW_TOP_PADDING)
        self.auto_time_box = gtk.HBox(spacing=BETWEEN_SPACING)
        self.auto_time_label = self.__setup_label(_("NTP"))
        self.auto_time_toggle = self.__setup_toggle()
        is_auto_set_time = self.datetime_settings.get_boolean("is-auto-set")
        if is_auto_set_time:
            #AutoSetTimeThread(self).start()
            self.__deepin_dt.set_using_ntp(True)
        else:
            self.__deepin_dt.set_using_ntp(False)
        self.auto_time_toggle_align = self.__setup_align(padding_top=4)
        self.auto_time_toggle.set_active(is_auto_set_time)
        self.auto_time_toggle.connect("toggled", self.__toggled,
                                      "auto_time_toggle")
        self.auto_time_toggle_align.add(self.auto_time_toggle)
        '''
        set time
        '''
        self.set_time_spin_align = self.__setup_align(padding_left=10,
                                                      padding_top=1)
        self.set_time_box = gtk.HBox(spacing=BETWEEN_SPACING)
        self.set_time_label = self.__setup_label(_("Set Time"), 60)
        self.set_time_spin = TimeSpinBox(is_24hour=self.is_24hour)
        self.set_time_spin.set_size_request(85, WIDGET_HEIGHT)
        self.set_time_spin.connect("value-changed", self.__time_changed)
        self.__widget_pack_start(self.set_time_box,
                                 [self.set_time_label, self.set_time_spin])
        self.set_time_spin_align.add(self.set_time_box)
        self.__widget_pack_start(self.auto_time_box, [
            self.auto_time_label, self.auto_time_toggle_align,
            self.set_time_spin_align
        ])
        if is_auto_set_time:
            self.set_time_spin_align.set_child_visible(False)
        self.auto_time_align.add(self.auto_time_box)
        '''
        24hour display
        '''
        self.time_display_align = self.__setup_align(
            padding_top=BETWEEN_SPACING)
        self.time_display_box = gtk.HBox(spacing=BETWEEN_SPACING)
        self.time_display_label = self.__setup_label("24 %s" % _("Hour"))
        self.time_display_toggle_align = self.__setup_align()
        self.time_display_toggle = self.__setup_toggle()
        self.time_display_toggle.set_active(self.is_24hour)
        self.time_display_toggle.connect("toggled", self.__toggled,
                                         "time_display_toggle")
        self.time_display_toggle_align.add(self.time_display_toggle)
        self.__widget_pack_start(
            self.time_display_box,
            [self.time_display_label, self.time_display_toggle_align])
        self.time_display_align.add(self.time_display_box)
        '''
        timezone
        '''
        self.timezone_title_align = self.__setup_title_align(
            app_theme.get_pixbuf("datetime/globe-green.png"), _("Time Zone"),
            TEXT_WINDOW_TOP_PADDING)
        self.timezone_combo_align = self.__setup_align(padding_top=6)
        self.timezone_combo = ComboBox(self.timezone_items,
                                       max_width=340,
                                       fixed_width=340)
        self.timezone_combo.set_select_index(self.__deepin_dt.get_gmtoff() +
                                             11)
        self.timezone_combo.connect("item-selected",
                                    self.__combo_item_selected)
        self.timezone_combo_align.add(self.timezone_combo)

        self.__widget_pack_start(self.right_box, [
            self.time_title_align, self.cur_time_align,
            self.datetime_widget_align, self.auto_time_align,
            self.time_display_align, self.timezone_title_align,
            self.timezone_combo_align
        ])
        self.right_align.add(self.right_box)

        self.__widget_pack_start(self, [self.left_align, self.right_align])

        self.connect("expose-event", self.__expose)

        self.__send_message("status", ("date_time", ""))

        SecondThread(self).start()
        DateThread(self).start()
Example #6
0
from dtk.ui.application import Application
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT

if __name__ == "__main__":
    # Init application.
    application = Application()

    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)

    # Set application icon.
    application.set_icon(os.path.join(get_current_dir(__file__), "icon.ico"))

    # Set application preview pixbuf.
    application.set_skin_preview(
        os.path.join(get_current_dir(__file__), "frame.png"))

    # Add titlebar.
    application.add_titlebar(
        ["theme", "max", "min", "close"],
        os.path.join(get_current_dir(__file__), "logo.png"),
        "TimeZone demo",
        "TimeZone demo",
    )

    deepin_lunar_obj = deepin_lunar.new()
    deepin_lunar_obj.mark_day(11)
    application.main_box.pack_start(deepin_lunar_obj.get_handle())

    application.run()