def _init_widgets(self):

        state = self._state

        if state is None:
            return

        if state.arch.name not in self.ARCH_REGISTERS:
            l.error(
                "Architecture %s is not listed in QRegisterViewer.ARCH_REGISTERS.",
                state.arch.name)
            return

        layout = QVBoxLayout()
        area = QScrollArea()
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        regs = self.ARCH_REGISTERS[state.arch.name]

        # common ones
        common_regs = regs['common']

        for reg_name in common_regs:
            sublayout = QHBoxLayout()

            lbl_reg_name = QLabel(self)
            lbl_reg_name.setProperty('class', 'reg_viewer_label')
            lbl_reg_name.setText(reg_name)
            lbl_reg_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            sublayout.addWidget(lbl_reg_name)

            sublayout.addSpacing(10)
            reg_value = QASTViewer(None, parent=self)
            self._registers[reg_name] = reg_value
            sublayout.addWidget(reg_value)

            layout.addLayout(sublayout)

        layout.setSpacing(0)
        layout.addStretch(0)
        layout.setContentsMargins(2, 2, 2, 2)

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        area.setWidget(container)

        base_layout = QVBoxLayout()
        base_layout.addWidget(area)
        self.setLayout(base_layout)
示例#2
0
 def layoutWidgets(self):
     layout = QVBoxLayout()
     hbox = QHBoxLayout()
     hbox.addWidget(self.indexLabel)
     hbox.addSpacing(self.fontMetrics().width("W") * 4)
     hbox.addStretch()
     hbox.addWidget(self.gotoLabel)
     hbox.addWidget(self.gotoLineEdit, 1)
     hbox.addWidget(self.helpButton)
     layout.addLayout(hbox)
     layout.addWidget(self.view, 1)
     self.setLayout(layout)
示例#3
0
class MainWindow(QDialog):

	def __init__(self, parent=None):
		super(MainWindow, self).__init__(parent)
		self.h0        = QHBoxLayout()
		self.lineArray = []
		labelArray     = [u'時間', u'值班', u'救護勤務', u'備勤', u'待命服勤', u'水源查察', u'消防查察', u'宣導勤務', u'訓(演)練', u'專案勤務', u'南山救護站']
		for i in labelArray:
			label = QLabel(i)
			label.setFixedWidth(100)
			label.setAlignment(Qt.AlignCenter)
			self.h0.addWidget(label)
			self.h0.addSpacing(15)

		self.v0 = QVBoxLayout()
		self.v0.addLayout(self.h0)

		for i in xrange(24):	
			hn = QHBoxLayout()
			for j in xrange(len(labelArray)):
				if j == 0:
					time = i+8 if (i+8)< 24 else i+8-24
					line = QLabel("%s:00~%s:00" % (str(time).zfill(2), str(time+1).zfill(2)))
				else:
					line = QLineEdit()
					self.lineArray.append(line)
				line.setFixedWidth(100)
				hn.addSpacing(15)					
				hn.addWidget(line)


			self.v0.addLayout(hn)
		self.h1 = QHBoxLayout()
		
		self.clearPB = QPushButton("Clear All")
		self.clearPB.setFixedWidth(200)
		self.clearPB.setFixedHeight(50)
		self.clearPB.clicked.connect(self.clear)
		self.h1.addStretch()
		self.h1.addWidget(self.clearPB)
		self.h1.addStretch()

		self.v0.addLayout(self.h1)

		self.setLayout(self.v0)

	def clear(self):
		for each in self.lineArray:
			each.setText('')
    def _load_tmps(self):

        state = self._state

        layout = QVBoxLayout()

        self._tmps.clear()
        if state is None:
            tmps = {}
        else:
            tmps = state.scratch.temps

        # tmps
        for tmp_id, tmp_value in tmps.iteritems():
            sublayout = QHBoxLayout()

            lbl_tmp_name = QLabel(self)
            lbl_tmp_name.setProperty('class', 'reg_viewer_label')
            lbl_tmp_name.setText("tmp_%d" % tmp_id)
            lbl_tmp_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            sublayout.addWidget(lbl_tmp_name)

            sublayout.addSpacing(10)

            tmp_viewer = QASTViewer(tmp_value, parent=self)
            self._tmps[tmp_id] = tmp_viewer
            sublayout.addWidget(tmp_viewer)

            layout.addLayout(sublayout)

        layout.setSpacing(0)
        layout.addStretch(0)
        layout.setContentsMargins(2, 2, 2, 2)

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        self._area.setWidget(container)
示例#5
0
    def __init__(self, *args, **kw):
        super(ComboBoxWidget, self).__init__(*args, **kw)

        layout = QHBoxLayout()
        layout.setSpacing(2)
        self.combo = combo = QComboBox()
        combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        combo.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)

        self.button = button = QPushButton()
        button.setEnabled(False)
        button.setIcon(icon('add').create_icon())
        button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        button.setFixedWidth(20)
        button.setFixedHeight(20)

        layout.addWidget(combo)
        layout.addSpacing(10)
        layout.addWidget(button)
        self.setLayout(layout)
示例#6
0
    def __init__(self, *args, **kw):
        super(ComboBoxWidget, self).__init__(*args, **kw)

        layout = QHBoxLayout()
        layout.setSpacing(2)
        self.combo = combo = QComboBox()
        combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        combo.setSizePolicy(QSizePolicy.Maximum,
                            QSizePolicy.Fixed)

        self.button = button = QPushButton()
        button.setEnabled(False)
        button.setIcon(icon('add').create_icon())
        button.setSizePolicy(QSizePolicy.Fixed,
                             QSizePolicy.Fixed)
        button.setFixedWidth(20)
        button.setFixedHeight(20)

        layout.addWidget(combo)
        layout.addSpacing(10)
        layout.addWidget(button)
        self.setLayout(layout)
示例#7
0
    def initUi(self):
        # button for interface expansion with name on it
        self.expButton = QPushButton(self.name, self)
        self.expButton.setCheckable(True)
        self.expButton.setChecked(False) #start unexpanded
        
        
        #level designates the value on the side of the name shown.. 
        # 0: top-level interface component
        # 1: method component
        # 2: custom value component (pipeline components, practically) Need to provide valueGuiElem on contructor.
        if self.level == 0:
            # slider for switching interface activity state, 3 states: active, tentative, disabled
            self.valueGuiElem = ActivationSlider(self)
        elif self.level == 1:
            self.valueGuiElem = MethodValueLabel(self)
        else:
            if self.valueGuiElem == None: 
                print "Warning: custom ui field empty, component level custom!"
        
        
        # connect the toggle signal to the expansion method
        self.expButton.toggled[bool].connect( self.showMethodElems )

        lo = QHBoxLayout()
            
        lo.addSpacing( self.level * 15 )    
        lo.addWidget( self.expButton )
        if self.valueGuiElem: lo.addWidget( self.valueGuiElem )
          
          
        mainLayout = QVBoxLayout()
        mainLayout.addLayout(lo)
            
        self.setFrameStyle( QFrame.Box | QFrame.Raised )

        self.setLayout( mainLayout )
示例#8
0
    def __init__(self, tag, text, parent, handler, icon=None):
        """Constructs a DropPanel

           tag
               A string associated with this DropPanel

           text
               The text displayed on this DropPanel

           parent
               The Qt GUI parent of this panel

           handler
               The datatree index list and tag will be passed to this
               function.

           icon
               Optional QIcon to display on this panel.
        """
        super(DropPanel, self).__init__(parent)

        self.setAcceptDrops(True)
        self.handler = handler
        self.tag = tag
        self.setPalette(QColor(0, 0, 0, 0))

        layout = QHBoxLayout(self)
        layout.setAlignment(Qt.AlignCenter)
        if icon is not None:
            label = QLabel("", parent=self)
            label.setPixmap(icon)
            layout.addWidget(label)
            layout.addSpacing(5)
        textlabel = QLabel(text)
        textlabel.setStyleSheet("QLabel { color : white; }")
        layout.addWidget(textlabel)
示例#9
0
文件: GUIUtils.py 项目: LLNL/boxfish
    def __init__(self, tag, text, parent, handler, icon = None):
        """Constructs a DropPanel

           tag
               A string associated with this DropPanel

           text
               The text displayed on this DropPanel

           parent
               The Qt GUI parent of this panel

           handler
               The datatree index list and tag will be passed to this
               function.

           icon
               Optional QIcon to display on this panel.
        """
        super(DropPanel, self).__init__(parent)

        self.setAcceptDrops(True)
        self.handler = handler
        self.tag = tag
        self.setPalette(QColor(0,0,0,0))

        layout = QHBoxLayout(self)
        layout.setAlignment(Qt.AlignCenter)
        if icon is not None:
            label = QLabel("", parent = self)
            label.setPixmap(icon)
            layout.addWidget(label)
            layout.addSpacing(5)
        textlabel = QLabel(text)
        textlabel.setStyleSheet("QLabel { color : white; }");
        layout.addWidget(textlabel)
示例#10
0
 def setlayoutH(self):
     """Présentation de QHBoxLayout"""
     self.setWindowTitle("Horizontal Layout")
     horizontalLayout = QHBoxLayout(self)
     boutton1 = QPushButton("I'm first", self)
     boutton2 = QPushButton("I'm second", self)
     boutton3 = QPushButton("I'm third", self)
     boutton4 = QPushButton("I'm fourth", self)
     horizontalLayout.addWidget(boutton1)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton2)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton3)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton4)
     self.setLayout(horizontalLayout)
示例#11
0
 def setlayoutH(self):
     """Présentation de QHBoxLayout"""
     self.setWindowTitle("Horizontal Layout")
     horizontalLayout = QHBoxLayout(self)
     boutton1 = QPushButton("I'm first", self)
     boutton2 = QPushButton("I'm second", self)
     boutton3 = QPushButton("I'm third", self)
     boutton4 = QPushButton("I'm fourth", self)
     horizontalLayout.addWidget(boutton1)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton2)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton3)
     horizontalLayout.addSpacing(44)
     horizontalLayout.addWidget(boutton4)
     self.setLayout(horizontalLayout)