本文整理汇总了Python中PyQt4.QtGui.QGraphicsGridLayout.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsGridLayout.addItem方法的具体用法?Python QGraphicsGridLayout.addItem怎么用?Python QGraphicsGridLayout.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsGridLayout
的用法示例。
在下文中一共展示了QGraphicsGridLayout.addItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WeatherApplet
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [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)
#.........这里部分代码省略.........
示例2: TaskCoachApplet
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
class TaskCoachApplet(plasmascript.Applet):
def __init__(self,parent,args=None):
plasmascript.Applet.__init__(self,parent)
def init(self):
self.setHasConfigurationInterface(False)
self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
self.settings = self.config()
self.theme = Plasma.Svg(self)
self.theme.setImagePath("widgets/background")
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.layout = QGraphicsGridLayout(self.applet)
self.layout.setColumnSpacing(0,5.0)
# using the predefined KGuiItem objects save us a lot of work
self.btnOpen = Plasma.PushButton(self.applet)
self.btnOpen.nativeWidget().setGuiItem(KStandardGuiItem.Open)
self.btnReset = Plasma.PushButton(self.applet)
self.btnReset.nativeWidget().setGuiItem(KStandardGuiItem.Reset)
self.btnSave = Plasma.PushButton(self.applet)
self.btnSave.nativeWidget().setGuiItem(KStandardGuiItem.Save)
self.btnSaveAs = Plasma.PushButton(self.applet)
self.btnSaveAs.nativeWidget().setGuiItem(KStandardGuiItem.SaveAs)
self.layout.addItem(self.btnOpen,0,0)
self.layout.addItem(self.btnReset,0,1)
self.layout.addItem(self.btnSave,2,1)
self.layout.addItem(self.btnSaveAs,2,0)
self.model = None
self.filePath = None
self.treeView = Plasma.TreeView(self.applet)
self.treeView.setVisible(False)
header = self.treeView.nativeWidget().header()
header.setDefaultAlignment(Qt.AlignCenter)
fontColor = self.theme.theme().color(Plasma.Theme.TextColor)
header.setStyleSheet("""
QHeaderView {
color: %s;
font: bold italic;
};
""" % fontColor.name() )
self.treeView.setStyleSheet("""
QTreeView { background-color: transparent; color: %s;};
""" % fontColor.name() )
self.treeView.setModel(self.model)
self.layout.addItem(self.treeView,1,0,1,2)
self.setLayout(self.layout)
self.resize(350,500)
self.btnOpen.clicked.connect(self.openFile)
self.btnReset.clicked.connect(self.resetFile)
self.btnSave.clicked.connect(self.saveFile)
self.btnSaveAs.clicked.connect(self.saveFileAs)
# FIXME: doesn't work
QObject.connect(self.treeView.nativeWidget(),
SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
self.onDataChanged)
self.treeView.nativeWidget().setItemDelegate(
ProgressDelegate(
self.treeView.nativeWidget()))
self.treeView.nativeWidget().header().setResizeMode(
QHeaderView.Interactive)
self.treeView.nativeWidget().setEditTriggers(QTreeView.AllEditTriggers)
def _open(self,filePath):
if not filePath.isEmpty():
self.model = TaskListModel(str(filePath))
self.treeView.setModel(self.model)
self.treeView.nativeWidget().expandAll()
self.treeView.nativeWidget().header().resizeSection(0,
self.treeView.nativeWidget().width() * 0.8)
self.treeView.nativeWidget().header().resizeSection(1,
self.treeView.nativeWidget().width() * 0.1)
self.filePath = filePath
self.treeView.setVisible(True)
@pyqtSlot()
def openFile(self,*args):
fPath = QFileDialog.getOpenFileName(None,
"Select TaskCoach file",
expanduser("~"),
"TaskCoach files (*.tsk);;All Files(*.*)")
#.........这里部分代码省略.........
示例3: OWDistanceMap
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
#.........这里部分代码省略.........
step=0.05, ticks=True, intOnly=False,
createLabel=False, callback=self._update_color)
)
form.addRow(
"High",
gui.hSlider(box, self, "color_high", minValue=0.0, maxValue=1.0,
step=0.05, ticks=True, intOnly=False,
createLabel=False, callback=self._update_color)
)
box.layout().addLayout(form)
box = gui.widgetBox(self.controlArea, "Annotations")
self.annot_combo = gui.comboBox(box, self, "annotation_idx",
callback=self._invalidate_annotations,
contentsLength=12)
self.annot_combo.setModel(itemmodels.VariableListModel())
self.annot_combo.model()[:] = ["None", "Enumeration"]
self.controlArea.layout().addStretch()
gui.auto_commit(self.controlArea, self, "autocommit",
"Send data", "Auto send is on")
self.inline_graph_report()
self.view = pg.GraphicsView(background="w")
self.mainArea.layout().addWidget(self.view)
self.grid_widget = pg.GraphicsWidget()
self.grid = QGraphicsGridLayout()
self.grid_widget.setLayout(self.grid)
self.viewbox = pg.ViewBox(enableMouse=False, enableMenu=False)
self.viewbox.setAcceptedMouseButtons(Qt.NoButton)
self.viewbox.setAcceptHoverEvents(False)
self.grid.addItem(self.viewbox, 1, 1)
self.left_dendrogram = DendrogramWidget(
self.grid_widget, orientation=DendrogramWidget.Left,
selectionMode=DendrogramWidget.NoSelection,
hoverHighlightEnabled=False
)
self.left_dendrogram.setAcceptedMouseButtons(Qt.NoButton)
self.left_dendrogram.setAcceptHoverEvents(False)
self.top_dendrogram = DendrogramWidget(
self.grid_widget, orientation=DendrogramWidget.Top,
selectionMode=DendrogramWidget.NoSelection,
hoverHighlightEnabled=False
)
self.top_dendrogram.setAcceptedMouseButtons(Qt.NoButton)
self.top_dendrogram.setAcceptHoverEvents(False)
self.grid.addItem(self.left_dendrogram, 1, 0)
self.grid.addItem(self.top_dendrogram, 0, 1)
self.right_labels = TextList(
alignment=Qt.AlignLeft)
self.bottom_labels = TextList(
orientation=Qt.Horizontal, alignment=Qt.AlignRight)
self.grid.addItem(self.right_labels, 1, 2)
self.grid.addItem(self.bottom_labels, 2, 1)
self.view.setCentralItem(self.grid_widget)
self.left_dendrogram.hide()
示例4: OWDistanceMap
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
class OWDistanceMap(widget.OWWidget):
name = "Distance Map"
description = "Visualize a distance matrix"
icon = "icons/DistanceMatrix.svg"
priority = 1200
inputs = [("Distances", Orange.misc.DistMatrix, "set_distances")]
outputs = [("Data", Orange.data.Table), ("Features", widget.AttributeList)]
display_grid = settings.Setting(False)
sorting = settings.Setting(0)
colormap = settings.Setting(0)
color_gamma = settings.Setting(0.0)
color_low = settings.Setting(0.0)
color_high = settings.Setting(1.0)
annotation_idx = settings.Setting(0)
autocommit = settings.Setting(True)
def __init__(self, parent=None):
super().__init__(parent)
self.matrix = None
self._tree = None
self._ordered_tree = None
self._sorted_matrix = None
self._sort_indices = None
self._selection = None
box = gui.widgetBox(self.controlArea, "Element sorting", margin=0)
gui.comboBox(box, self, "sorting",
items=["None", "Clustering",
"Clustering with ordered leaves"
],
callback=self._invalidate_ordering)
box = gui.widgetBox(self.controlArea, "Colors")
self.colormap_cb = gui.comboBox(
box, self, "colormap", callback=self._update_color
)
self.colormap_cb.setIconSize(QSize(64, 16))
self.palettes = list(sorted(load_default_palettes()))
init_color_combo(self.colormap_cb, self.palettes, QSize(64, 16))
self.colormap_cb.setCurrentIndex(self.colormap)
form = QFormLayout(
formAlignment=Qt.AlignLeft,
labelAlignment=Qt.AlignLeft,
fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
)
# form.addRow(
# "Gamma",
# gui.hSlider(box, self, "color_gamma", minValue=0.0, maxValue=1.0,
# step=0.05, ticks=True, intOnly=False,
# createLabel=False, callback=self._update_color)
# )
form.addRow(
"Low",
gui.hSlider(box, self, "color_low", minValue=0.0, maxValue=1.0,
step=0.05, ticks=True, intOnly=False,
createLabel=False, callback=self._update_color)
)
form.addRow(
"High",
gui.hSlider(box, self, "color_high", minValue=0.0, maxValue=1.0,
step=0.05, ticks=True, intOnly=False,
createLabel=False, callback=self._update_color)
)
box.layout().addLayout(form)
box = gui.widgetBox(self.controlArea, "Annotations")
self.annot_combo = gui.comboBox(box, self, "annotation_idx",
callback=self._invalidate_annotations)
self.annot_combo.setModel(itemmodels.VariableListModel())
self.annot_combo.model()[:] = ["None", "Enumeration"]
self.controlArea.layout().addStretch()
gui.auto_commit(self.controlArea, self, "autocommit",
"Send data", "Auto send is on")
self.view = pg.GraphicsView(background="w")
self.mainArea.layout().addWidget(self.view)
self.grid_widget = pg.GraphicsWidget()
self.grid = QGraphicsGridLayout()
self.grid_widget.setLayout(self.grid)
self.viewbox = pg.ViewBox(enableMouse=False)
self.viewbox.setAcceptedMouseButtons(Qt.NoButton)
self.viewbox.setAcceptHoverEvents(False)
self.grid.addItem(self.viewbox, 1, 1)
self.left_dendrogram = DendrogramWidget(
self.grid_widget, orientation=DendrogramWidget.Left)
self.left_dendrogram.setAcceptedMouseButtons(Qt.NoButton)
self.left_dendrogram.setAcceptHoverEvents(False)
#.........这里部分代码省略.........
示例5: HelloWorldApplet
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
#.........这里部分代码省略.........
print "osman"
if self.link.Network.Firewall[dbus.String("iptables")].getState()==dbus.String(u"on"):
self.bilgi_label.setText("<p style='color:green'>Firewall is working now.</p>")
self.kilit.setIcon("object-locked")
self.kilit.setMaximumSize(32,32)
self.kilit.setMinimumSize(32,32)
self.baslat_pb.setEnabled(False)
else:
self.bilgi_label.setText("<p style='color:red'>Firewall is stopped now.</p>")
self.kilit.setMaximumSize(32,32)
self.kilit.setMinimumSize(32,32)
self.kilit.setIcon("object-unlocked")
self.durdur_pb.setEnabled(False)
self.bilgilendirme_baslik=Plasma.Label(self.applet)
self.bilgilendirme_baslik.setText("Latest news:")
self.bilgilendirme=Plasma.Label(self.applet)
self.bilgilendirme.setText("Firewall Plasmoid has been started.")
gelen_simge=Plasma.IconWidget(self.applet)
gelen_simge.setIcon("application-x-smb-workgroup")
paylasim_simge=Plasma.IconWidget(self.applet)
paylasim_simge.setIcon("application-x-smb-server")
giden_simge=Plasma.IconWidget(self.applet)
giden_simge.setIcon("security-medium")
self.kutular=[]
sayi=0
for i in self.moduller:
self.kutular.append(Plasma.CheckBox(self.applet))
self.kutular[sayi].setText(self.link.Network.Firewall[dbus.String("iptables")].moduleInfo(i)[0])
sayi+=1
self.layout.addItem(label, 0, 0,1,4)
self.layout.addItem(self.kilit, 1,0)
self.layout.addItem(self.bilgi_label,1,1)
self.layout.addItem(self.baslat_pb,1,2)
self.layout.addItem(self.durdur_pb,1,3)
self.layout.addItem(gelen_simge,2,0,1,1)
self.layout.addItem(paylasim_simge,3,0,1,1)
self.layout.addItem(giden_simge,4,0,1,1)
self.layout.addItem(self.bilgilendirme_baslik, 5,0,1,1)
self.layout.addItem(self.bilgilendirme, 5,1,1,4)
m=0
for i in range(0,len(self.moduller)):
self.layout.addItem(self.kutular[m], m+2,1,1,4)
m+=1
self.applet.setLayout(self.layout)
QObject.connect(self.baslat_pb, SIGNAL("clicked()"), self.baslat)
QObject.connect(self.durdur_pb, SIGNAL("clicked()"), self.durdur)
fonksiyonlar=[self.blockGelen, self.paylasim, self.blockGiden]
for i in range(0, len(self.moduller)):
QObject.connect(self.kutular[i], SIGNAL("toggled(bool)"), fonksiyonlar[i])
self.bilgilendirme_iletileri=["Incoming connections was blocked successfully.",
"Sharing internet is successful.",
"Outgoing connections was blocked successfully."]
self.link.listenSignals("Network.Firewall", self.handler)
def handler(self, *args):
"""Handler method for receiving signals from Comar"""
if self.link.Network.Firewall[dbus.String("iptables")].getState()==dbus.String(u"on"):
self.bilgi_label.setText("<p style='color:green'>Firewall is working now.</p>")
self.kilit.setIcon("object-locked")
self.durdur_pb.setEnabled(True)
self.baslat_pb.setEnabled(False)
#print "baslat sinyali"
else:
self.bilgi_label.setText("<p style='color:red'>Firewall is stopped now.</p>")
self.kilit.setIcon("object-unlocked")
self.durdur_pb.setEnabled(False)
self.baslat_pb.setEnabled(True)
#print "durdur sinyali"
if self.link.Network.Firewall[dbus.String("iptables")].getModuleState("block_incoming")==dbus.String(u"on"):
self.kutular[0].setChecked(True)
#print "ilk kutu tiklandi sinyali"
else:
self.kutular[0].setChecked(False)
#print "ilk kutu tiki kaldirildi sinyali"
if self.link.Network.Firewall[dbus.String("iptables")].getModuleState("internet_sharing")==dbus.String(u"on"):
self.kutular[1].setChecked(True)
#print "ikinci kutu tiklandi sinyali"
else:
self.kutular[1].setChecked(False)
#print "ikinci kutu tiki kaldirildi sinyali"
if self.link.Network.Firewall[dbus.String("iptables")].getModuleState("block_outgoing")==dbus.String(u"on"):
self.kutular[2].setChecked(True)
#print "ucuncu kutu tiklandi sinyali"
else:
self.kutular[2].setChecked(False)
示例6: CurrencyConverter
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
#.........这里部分代码省略.........
self.conversion_result.nativeWidget().setReadOnly(True)
self.credits_label = Plasma.Label()
self.credits_label.setAlignment(Qt.AlignRight)
self.credits_label.nativeWidget().setOpenExternalLinks(True)
logo = "%scontents/images/yahoo-attribution.png" % self.applet.package().path()
self.credits_label.setText(i18n("Data from <a href=\"http://finance.yahoo.com/currency-converter\"><img src=\"%s\"</a>" % logo))
f = self.credits_label.nativeWidget().font()
f.setPointSize(self.font_size()-2)
self.credits_label.nativeWidget().setFont(f)
QObject.connect(self.credits_label.nativeWidget(), SIGNAL("linkActivated(const QString&)"), self.open_link)
QObject.connect(self.credits_label, SIGNAL("linkActivated(const QString&)"), self.open_link)
self.credits_label.linkActivated.connect(self.open_link)
# Limit the number of currencies shown at a time if docked in bottom panel.
#if ((self.applet.formFactor() == Plasma.Horizontal) or (self.applet.formFactor() == Plasma.Vertical)):
if ((self.applet.formFactor() == Plasma.Horizontal) and (self.applet.location() == Plasma.BottomEdge)):
self.currency_from.nativeWidget().setMaxVisibleItems(6)
self.currency_to.nativeWidget().setMaxVisibleItems(4)
m_locale = KGlobal.locale()
#cc_list = l.currency().allCurrencyCodesList(KCurrencyCode.ActiveCurrency|KCurrencyCode.SuspendedCurrency|KCurrencyCode.ObsoleteCurrency)
cc_list = m_locale.currency().allCurrencyCodesList(KCurrencyCode.ActiveCurrency)
cc_namelist = []
#print "CC's:", len(l.currency().allCurrencyCodesList())
#print "# KDE Currency Codes:", len(cc_list)
for cc in cc_list:
cc_namelist.append(i18nc( "@item currency name and currency code", "%1 (%2)",
m_locale.currency().currencyCodeToName( cc ), cc ) )
#cc_namelist.sort()
for cur in sorted(set(cc_namelist)):
#print u"Currency:", unicode(cur)
self.currency_from.nativeWidget().addItem( cur, QVariant( cur.mid( cur.length()-4, 3 ) ) )
self.currency_to.nativeWidget().addItem( cur, QVariant( cur.mid( cur.length()-4, 3 ) ) )
self.currency_from.nativeWidget().setCurrentIndex( self.currency_from.nativeWidget().findData( QVariant( self.def_from ) ) )
self.currency_to.nativeWidget().setCurrentIndex( self.currency_to.nativeWidget().findData( QVariant( self.def_to ) ) )
self.currency_from.textChanged.connect(self.currency_changed)
self.currency_to.textChanged.connect(self.currency_changed)
self.layout_widgets()
if self.applet.nwmon.connected():
self.applet.setBusy(False)
self.start_timer()
def open_link(self, lnk):
print "open_link:", lnk
def start_timer(self):
print "CurrencyConverter::start_timer '%s'" % self.update_interval
if not self.timer:
self.timer = QTimer(self)
else:
self.timer.stop()
if self.update_interval > 0:
self.timer.setInterval(1000*60*self.update_interval)
self.timer.timeout.connect(self.do_convert)
self.timer.start()
self.do_convert()
def setEnabled(self, state):
self.collapse_button.setEnabled(state)
self.invert_button.setEnabled(state)
示例7: replot_experiments
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
def replot_experiments(self):
"""Replot the whole quality plot.
"""
self.scene.clear()
labels = []
max_dist = numpy.nanmax(list(filter(None, self.distances)))
rug_widgets = []
group_pen = QPen(Qt.black)
group_pen.setWidth(2)
group_pen.setCapStyle(Qt.RoundCap)
background_pen = QPen(QColor(0, 0, 250, 150))
background_pen.setWidth(1)
background_pen.setCapStyle(Qt.RoundCap)
main_widget = QGraphicsWidget()
layout = QGraphicsGridLayout()
attributes = self.data.domain.attributes
if self.data is not None:
for (group, indices), dist_vec in zip(self.groups, self.distances):
indices_set = set(indices)
rug_items = []
if dist_vec is not None:
for i, attr in enumerate(attributes):
# Is this a within group distance or background
in_group = i in indices_set
if in_group:
rug_item = ClickableRugItem(dist_vec[i] / max_dist,
1.0, self.on_rug_item_clicked)
rug_item.setPen(group_pen)
tooltip = experiment_description(attr)
rug_item.setToolTip(tooltip)
rug_item.group_index = indices.index(i)
rug_item.setZValue(rug_item.zValue() + 1)
else:
rug_item = ClickableRugItem(dist_vec[i] / max_dist,
0.85, self.on_rug_item_clicked)
rug_item.setPen(background_pen)
tooltip = experiment_description(attr)
rug_item.setToolTip(tooltip)
rug_item.group = group
rug_item.index = i
rug_item.in_group = in_group
rug_items.append(rug_item)
rug_widget = RugGraphicsWidget(parent=main_widget)
rug_widget.set_rug(rug_items)
rug_widgets.append(rug_widget)
label = group_label(self.selected_split_by_labels(), group)
label_item = QGraphicsSimpleTextItem(label, main_widget)
label_item = GraphicsSimpleTextLayoutItem(label_item, parent=layout)
label_item.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
labels.append(label_item)
for i, (label, rug_w) in enumerate(zip(labels, rug_widgets)):
layout.addItem(label, i, 0, Qt.AlignVCenter)
layout.addItem(rug_w, i, 1)
layout.setRowMaximumHeight(i, 30)
main_widget.setLayout(layout)
self.scene.addItem(main_widget)
self.main_widget = main_widget
self.rug_widgets = rug_widgets
self.labels = labels
self.on_view_resize(self.scene_view.size())
示例8: GSBApplet
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
class GSBApplet(plasmascript.Applet):
def __init__(self,parent,args=None):
plasmascript.Applet.__init__(self,parent)
def init(self):
self.setHasConfigurationInterface(True)
self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
self.settings = self.config()
self.theme = Plasma.Svg(self)
self.theme.setImagePath("widgets/background")
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.layout = QGraphicsGridLayout(self.applet)
self.layout.setColumnSpacing(0,5.0)
self.lblTitle = Plasma.Label(self.applet)
self.lblTitle.nativeWidget().setText(
ki18n("Stuff to get back").toString())
self.lblTitle.setAlignment(Qt.AlignHCenter)
self.lblTitle.setStyleSheet("""QLabel {
text-align:center;
font-style: italic;
font-weight: bold;}""")
self.layout.addItem(self.lblTitle,0,0,1,3)
self.btnAdd = Plasma.PushButton(self.applet)
self.btnAdd.nativeWidget().setGuiItem(KStandardGuiItem.Add)
self.layout.addItem(self.btnAdd,1,0)
self.btnRemove = Plasma.PushButton(self.applet)
self.btnRemove.nativeWidget().setGuiItem(KStandardGuiItem.Remove)
self.layout.addItem(self.btnRemove,1,2)
self.db = GSBDbModel()
self.view = Plasma.TreeView(self.applet)
self.view.setModel(self.db)
self.view.nativeWidget().setColumnHidden(self.db.IDCOL,True)
self.view.nativeWidget().setRootIsDecorated(False)
self.view.nativeWidget().setExpandsOnDoubleClick(False)
self.view.nativeWidget().setItemsExpandable(False)
self.view.setStyleSheet("""
QTreeView {
background-color: transparent;
}
QTreeView::item { padding-top:10px; padding-bottom: 10px; }
""")
self.view.nativeWidget().header().resizeSections(
QHeaderView.ResizeToContents)
self.view.nativeWidget().setItemDelegate(
LoanDelegate(
self.applet,
self.view.nativeWidget()))
self.layout.addItem(self.view,2,0,1,3)
self.setLayout(self.layout)
self.btnAdd.clicked.connect(self.add_loan)
self.btnRemove.clicked.connect(self.remove_loan)
def createConfigurationInterface(self, parent):
self.configDlg = ConfigDlg(parent, self.applet)
page = parent.addPage(self.configDlg,
ki18n("GetStuffBack Options").toString())
page.setIcon(KIcon("user-desktop"))
parent.okClicked.connect(self.configAccepted)
def showConfigurationInterface(self):
dialog = KPageDialog()
dialog.setFaceType(KPageDialog.List)
dialog.setButtons( KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel) )
self.createConfigurationInterface(dialog)
dialog.exec_()
@pyqtSlot()
def configAccepted(self):
grace_period = self.configDlg.spinGrace.value()
colour = self.configDlg.btnColour.color()
options = self.settings.group("general")
options.writeEntry("grace",grace_period)
options.writeEntry("overdue_colour",colour.name())
@pyqtSlot()
def add_loan(self,*args):
addDlg = AddDlg(self)
result = addDlg.exec_()
if result == False: return False
ln = Loan()
ln.item_description = unicode(addDlg.lineItemDescription.toPlainText())
ln.person = unicode(addDlg.linePerson.text())
ln.date = addDlg.dteDate.dateTime().toPyDateTime()
ln.expected_date = addDlg.dteExpectedDate.dateTime().toPyDateTime()
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
class FlowModule:
def __init__(self):
self.name = "Pretok"
self.updateTimer = QTimer()
self.updateTimer.timeout.connect(self.update)
def makeLayout(self):
self.layout = QGraphicsLinearLayout(Qt.Vertical)
self.flowComboLayout = QGraphicsLinearLayout(Qt.Horizontal)
self.flowLabelLayout = QGraphicsGridLayout()
#Flow Layout
self.flowData = SvJanez()
self.flowView = QGraphicsWebView()
self.flowView.setUrl( QUrl(self.flowData.flowImageUrl) )
self.flowView.setEnabled(False)
self.flowSelectorCombo = Plasma.ComboBox()
self.flowSelectorCombo.addItem(u"Sveti Janez")
self.flowSelectorCombo.addItem(u"Soteska")
self.flowSelectorCombo.setMinimumWidth(125)
self.flowSelectorCombo.textChanged.connect(self.flowSourceChanged)
self.flowRefresh = Plasma.IconWidget()
self.flowRefresh.setIcon("view-refresh")
self.flowRefresh.clicked.connect(self.update)
self.flowEnlargeButton = Plasma.IconWidget()
self.flowEnlargeButton.setIcon("zoom-in")
self.flowEnlargeButton.clicked.connect(self.showFullFlowWidget)
self.flowLabel = Plasma.Label()
self.flowLabel.setText(u"<b>Pretok:</b> ")
self.flowDataLabel = Plasma.Label()
self.flowLevelLabel = Plasma.Label()
self.flowLevelLabel.setText(u"<b>Višina:</b> ")
self.flowLevelDataLabel = Plasma.Label()
self.flowTempLabel = Plasma.Label()
self.flowTempLabel.setText(u"<b>Temperatura:</b> ")
self.flowTempDataLabel = Plasma.Label()
self.flowLabelLayout.addItem(self.flowLevelLabel,0,0)
self.flowLabelLayout.addItem(self.flowLevelDataLabel,0,1)
self.flowLabelLayout.addItem(self.flowLabel,1,0)
self.flowLabelLayout.addItem(self.flowDataLabel,1,1)
self.flowLabelLayout.addItem(self.flowTempLabel,2,0)
self.flowLabelLayout.addItem(self.flowTempDataLabel,2,1)
self.flowUpdateTimeSelector = UpdateTimeSelector()
self.flowUpdateTimeSelector.setDefaultTime(4)
self.flowUpdateTimeSelector.setDefaultInterval('h')
self.flowUpdateTimeSelector.updateTimeSpin.valueChanged.connect(self.flowTimeChanged)
self.flowUpdateTimeSelector.updateCheckBox.toggled.connect(self.flowTimerToggle)
self.flowComboLayout.addItem(self.flowSelectorCombo)
self.flowComboLayout.addStretch()
self.flowComboLayout.addItem(self.flowEnlargeButton)
self.flowComboLayout.addItem(self.flowRefresh)
self.layout.addItem(self.flowComboLayout)
self.layout.addItem(self.flowView)
self.layout.addItem(self.flowLabelLayout)
self.layout.addStretch()
self.layout.addItem(self.flowUpdateTimeSelector.layout)
self.layout.itemAt(0).setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed, QSizePolicy.DefaultType)
self.layout.itemAt(2).setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed, QSizePolicy.DefaultType)
def flowTimerToggle(self, toggled):
if toggled:
multiplier = 1
if self.flowUpdateTimeSelector.getInterval() == 'min':
multiplier = 60
if self.flowUpdateTimeSelector.getInterval() == 'h':
multiplier = 60 * 60
self.updateTimer.start(self.flowUpdateTimeSelector.getTime() * 1000 * multiplier)
self.update()
else:
self.updateTimer.stop()
def flowTimeChanged(self, value):
if self.flowUpdateTimeSelector.isChecked():
self.updateTimer.stop()
self.flowTimerToggle(self.flowUpdateTimeSelector.isChecked())
def flowSourceChanged(self, text):
if text == "Sveti Janez":
self.flowData = SvJanez()
else:
self.flowData = Soteska()
self.flowView.setUrl(QUrl(self.flowData.flowImageUrl))
self.updateFlowLabels()
def updateFlowImage(self):
self.flowSourceChanged(self.flowSelectorCombo.text())
def updateFlowLabels(self):
self.flowData.fetchData()
self.flowDataLabel.setText(u"%s %s" % (self.flowData.currentFlow, u' m3/s'))
self.flowTempDataLabel.setText(u"%s %s" % (self.flowData.temperature , u' °C'))
self.flowLevelDataLabel.setText(u"%s %s" % (self.flowData.waterLevel , u' cm'))
#.........这里部分代码省略.........
示例10: HelloWorldApplet
# 需要导入模块: from PyQt4.QtGui import QGraphicsGridLayout [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsGridLayout import addItem [as 别名]
class HelloWorldApplet(plasmascript.Applet):
def __init__(self,parent,args=None):
plasmascript.Applet.__init__(self,parent)
def init(self):
#self.moduller=self.link.Network.Firewall[dbus.String("iptables")].listModules()
self.tahta=[[0,0,0],[0,0,0],[0,0,0]]
self.setHasConfigurationInterface(True)
self.setAspectRatioMode(Plasma.Square)
self.resize(450,250)
self.theme = Plasma.Svg(self)
self.theme.setImagePath("widgets/background")
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.layout=QGraphicsGridLayout(self.applet)
#label = Plasma.Label(self.applet)
#label.setText("<h1>Firewall Plasmoid</h1>")
#self.kilit=Plasma.IconWidget(self.applet)
#self.bilgi_label=Plasma.Label(self.applet)
#self.baslat_pb=Plasma.PushButton(self.applet)
#self.baslat_pb.setText("Start")
#self.durdur_pb=Plasma.PushButton(self.applet)
#self.durdur_pb.setText("Stop")
self.tus1=Plasma.PushButton(self.applet)
self.tus1.setText("")
self.tus2=Plasma.PushButton(self.applet)
self.tus2.setText("")
self.tus3=Plasma.PushButton(self.applet)
self.tus3.setText("")
self.tus4=Plasma.PushButton(self.applet)
self.tus4.setText("")
self.tus5=Plasma.PushButton(self.applet)
self.tus5.setText("")
self.tus6=Plasma.PushButton(self.applet)
self.tus6.setText("")
self.tus7=Plasma.PushButton(self.applet)
self.tus7.setText("")
self.tus8=Plasma.PushButton(self.applet)
self.tus8.setText("")
self.tus9=Plasma.PushButton(self.applet)
self.tus9.setText("")
self.layout.addItem(self.tus1, 0, 0)
self.layout.addItem(self.tus2, 0, 1)
self.layout.addItem(self.tus3, 0, 2)
self.layout.addItem(self.tus4, 1, 0)
self.layout.addItem(self.tus5, 1, 1)
self.layout.addItem(self.tus6, 1, 2)
self.layout.addItem(self.tus7, 2, 0)
self.layout.addItem(self.tus8, 2, 1)
self.layout.addItem(self.tus9, 2, 2)
self.applet.setLayout(self.layout)
#QObject.connect(self.baslat_pb, SIGNAL("clicked()"), self.baslat)
#QObject.connect(self.durdur_pb, SIGNAL("clicked()"), self.durdur)
def hamle_yap(self):
pass