当前位置: 首页>>代码示例>>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;未经允许,请勿转载。