forecastw.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:my-weather-indicator 作者: atareao 项目源码 文件源码
def __init__(self, location, ws, weather):
        Gtk.Dialog.__init__(self, 'my-weather-indicator | ' + _('Forecast'),
                            None, Gtk.DialogFlags.MODAL |
                            Gtk.DialogFlags.DESTROY_WITH_PARENT)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(200, 200)
        self.connect('destroy', self.close_application)
        self.set_icon_from_file(comun.ICON)
        vbox0 = Gtk.VBox(spacing=5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        label11 = Gtk.Label(label='<b>' + location + '</b>')
        label11.set_markup('<b>' + location + '</b>')
        vbox0.pack_start(label11, True, True, 0)
        frame = Gtk.Frame()
        vbox0.add(frame)
        hbox1 = Gtk.HBox(spacing=5)
        hbox1.set_border_width(5)
        frame.add(hbox1)
        self.ws = ws
        forecast = weather['forecasts']
        self.table = Gtk.Table(rows=9, columns=5, homogeneous=False)
        self.table.set_col_spacings(10)
        self.create_labels()
        if self.ws == 'yahoo':
            total = 2
        if self.ws == 'wunderground':
            total = 4
        else:
            total = 5
        for i in range(0, total):
            self.create_forecast_dor_day(forecast, i)
        hbox1.add(self.table)
        #
        if self.ws == 'yahoo':
            filename = comun.YAHOOLOGO
            web = comun.YAHOOWEB
        elif self.ws == 'worldweatheronline':
            filename = comun.WOLRDWEATHERONLINE
            web = comun.WOLRDWEATHERONLINEWEB
        elif self.ws == 'openweathermap':
            filename = comun.OPENWEATHERMAPLOGO
            web = comun.OPENWEATHERMAPWEB
        elif self.ws == 'wunderground':
            filename = comun.UNDERGROUNDLOGO
            web = comun.UNDERGROUNDWEB
        image = load_image(filename, size=64)
        image.set_alignment(0.5, 0.5)
        button = Gtk.Button()
        button.set_image(image)
        button.connect('clicked', (lambda x: webbrowser.open(web)))
        hbox1.pack_start(button, True, True, 0)
        #
        self.show_all()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.run()
        self.destroy()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号