當前位置: 首頁>>代碼示例>>Python>>正文


Python QGraphicsGridLayout.setColumnMaximumWidth方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QGraphicsGridLayout.setColumnMaximumWidth方法的典型用法代碼示例。如果您正苦於以下問題:Python QGraphicsGridLayout.setColumnMaximumWidth方法的具體用法?Python QGraphicsGridLayout.setColumnMaximumWidth怎麽用?Python QGraphicsGridLayout.setColumnMaximumWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QGraphicsGridLayout的用法示例。


在下文中一共展示了QGraphicsGridLayout.setColumnMaximumWidth方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WeatherApplet

# 需要導入模塊: from PyQt4.QtGui import QGraphicsGridLayout [as 別名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import setColumnMaximumWidth [as 別名]
class WeatherApplet(plasmascript.Applet):
    def __init__(self, parent, args=None):
        plasmascript.Applet.__init__(self, parent)
        self._unit = "SI"
        self._image_prefix = ":/images/"

        self._img_width = 16
        self._img_height = 16
        self._big_img_width = 48
        self._big_img_height = 48
        self._fc_column_width = 100

    def init(self):
        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)

        # self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet)
        self.layout_main = QGraphicsGridLayout(self.applet)
        self.layout_top_left = QGraphicsLinearLayout(Qt.Vertical, self.layout_main)
        self.layout_bottom = QGraphicsGridLayout(self.layout_main)
        self.layout_bottom.setColumnMaximumWidth(0, self._fc_column_width)
        self.layout_bottom.setColumnMaximumWidth(1, self._fc_column_width)
        self.layout_bottom.setColumnMaximumWidth(2, self._fc_column_width)

        self.lb_location = Plasma.Label(self.applet)
        self.lb_temperature = Plasma.Label(self.applet)
        self.lb_condition = Plasma.Label(self.applet)
        self.lb_humidity = Plasma.Label(self.applet)
        self.lb_wind = Plasma.Label(self.applet)

        # create svg widgets for conditions
        self.svg_w_current = Plasma.SvgWidget(self.applet)
        self.svg_w_fc1 = Plasma.SvgWidget(self.applet)
        self.svg_w_fc2 = Plasma.SvgWidget(self.applet)
        self.svg_w_fc3 = Plasma.SvgWidget(self.applet)

        # self.svg_w_fc1.resize(self._img_width,self._img_height)

        # create labels for forecast
        self.lb_temp_fc1 = Plasma.Label(self.applet)
        self.lb_temp_fc2 = Plasma.Label(self.applet)
        self.lb_temp_fc3 = Plasma.Label(self.applet)

        self.lb_day_fc1 = Plasma.Label(self.applet)
        self.lb_day_fc2 = Plasma.Label(self.applet)
        self.lb_day_fc3 = Plasma.Label(self.applet)

        # create images to display conditions
        self.svg_current = Plasma.Svg(self.applet)
        self.svg_fc1 = Plasma.Svg(self.applet)
        self.svg_fc2 = Plasma.Svg(self.applet)
        self.svg_fc3 = Plasma.Svg(self.applet)

        self.layout_main.addItem(self.layout_top_left, 0, 0)
        self.layout_main.addItem(self.svg_w_current, 0, 1)
        self.layout_main.addItem(self.layout_bottom, 1, 0, 1, 2, Qt.Alignment(Qt.AlignCenter))

        # add current conditions
        self.layout_top_left.addItem(self.lb_location)
        self.layout_top_left.addItem(self.lb_temperature)
        self.layout_top_left.addItem(self.lb_condition)
        self.layout_top_left.addItem(self.lb_humidity)
        self.layout_top_left.addItem(self.lb_wind)

        # add forecast labels for days
        self.layout_bottom.addItem(self.lb_day_fc1, 0, 0, 1, 1, Qt.Alignment(Qt.AlignHorizontal_Mask))
        self.layout_bottom.addItem(self.lb_day_fc2, 0, 1, 1, 1, Qt.Alignment(Qt.AlignHCenter))
        self.layout_bottom.addItem(self.lb_day_fc3, 0, 2, 1, 1, Qt.Alignment(Qt.AlignHCenter))
        # add forecast images
        self.layout_bottom.addItem(self.svg_w_fc1, 1, 0, 1, 1, Qt.Alignment(Qt.AlignLeft))
        self.layout_bottom.addItem(self.svg_w_fc2, 1, 1, 1, 1, Qt.Alignment(Qt.AlignLeft))
        self.layout_bottom.addItem(self.svg_w_fc3, 1, 2, 1, 1, Qt.Alignment(Qt.AlignLeft))
        # add forecast labels for temp
        self.layout_bottom.addItem(self.lb_temp_fc1, 2, 0, 1, 1, Qt.Alignment(Qt.AlignCenter))
        self.layout_bottom.addItem(self.lb_temp_fc2, 2, 1, 1, 1, Qt.Alignment(Qt.AlignCenter))
        self.layout_bottom.addItem(self.lb_temp_fc3, 2, 2, 1, 1, Qt.Alignment(Qt.AlignCenter))

        self.setLayout(self.layout_main)
        self.resize(375, 375)

        self.checkWeather()

        self.timer = QTimer()
        self.connect(self.timer, SIGNAL("timeout()"), self.checkWeather)
        self.timer.start(0.5 * 60000)

    def checkWeather(self):
        wi = WeatherInfo()
        mapper = ConditionMapper()
        wi.parse()
        weather = Weather()
        weather.extractData(wi, self._unit)

        self.lb_location.setText("Location: " + weather.location)

        self.lb_temperature.setText(weather.current_temperature)
#.........這裏部分代碼省略.........
開發者ID:rangalo,項目名稱:plasma_pyweather,代碼行數:103,代碼來源:main.py


注:本文中的PyQt4.QtGui.QGraphicsGridLayout.setColumnMaximumWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。