Ejemplo n.º 1
0
    def _createSelectablePluginType(self, a: PluginAttribute):
        """
        Creates widget for attribute of SELECTABLE_PLUGIN type.
        
        :param a: The attribute.
        :type a: PluginAttribute
        :return: Widget for attribute.
        :rtype: QWidget
        """

        attrW = QWidget(self._widget)

        attrLayout = QVBoxLayout(attrW)
        attrLayout.setMargin(0)
        attrW.setLayout(attrLayout)

        inputW = QComboBox()
        inputW.addItems(
            [None if n is None else n.getName() for n in a.selVals])

        inputW.currentTextChanged.connect(self._pluginSelected(a, attrLayout))

        if a.value is not None:
            inputW.setCurrentText(str(a.value.getName()))

        resW = self._createWidget(a, inputW)
        resW.layout().addWidget(attrW)
        return resW
Ejemplo n.º 2
0
    def _createWidget(self, a, inputW: QWidget, vertical=True):
        """
        Creates widget for given attribute and input.
        
        :param a: The attribute.
        :type a: PluginAttribute
        :param inputW: Input that is used for value manipulation.
        :type inputW: QWidget
        :param vertical: True means QVBoxLayout and Fale means QHBoxLayout.
        :type vertical: bool
        :return: Widget for attribute.
        :rtype: QWidget
        """
        w = QWidget(self._widget)
        inputW.setParent(w)
        if vertical:
            layout = QVBoxLayout(w)
            layout.setContentsMargins(0, 5, 5, 0)
        else:
            layout = QHBoxLayout(w)
            layout.setMargin(0)

        w.setLayout(layout)

        label = QLabel(a.name + ":", self._widget)
        label.setTextInteractionFlags(Qt.TextSelectableByMouse
                                      | Qt.TextSelectableByKeyboard)
        label.setBuddy(inputW)

        layout.addWidget(label)
        layout.addWidget(inputW)

        return w
Ejemplo n.º 3
0
    def __init__(self, addStr: str, parent: any = None) -> None:
        '''按钮列表,默认有一个添加按钮的按钮

        Args:
            addStr(str):添加按钮上显示的文字
        '''
        super().__init__(parent=parent)

        self.addIterm = QPushButton(addStr, self)
        self.addIterm.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        # self.addIterm.resize(self.addIterm.sizeHint())
        self.addIterm.clicked.connect(self.addBtn_clicked)

        # 添加按钮布局
        self.layDown = QVBoxLayout()
        self.layDown.addWidget(self.addIterm)
        # 按钮布局,与addIterm所处的布局分开,防止删除按钮时布局的神秘错乱(我太菜了)
        self.layUp = QVBoxLayout()
        # 整体外布局
        lay = QVBoxLayout()
        lay.setMargin(3)  # 设置边距
        lay.addLayout(self.layUp)
        lay.addLayout(self.layDown)
        lay.addStretch(1)  # 添加拉伸因子,防止按钮由于父控件大小被纵向拉伸
        self.setLayout(lay)  # 应用布局
Ejemplo n.º 4
0
class UserSettings(QWidget):
    def __init__(self):
        super(UserSettings, self).__init__()
        UserSettingsSignal.put.connect(self.update)
        self.settings = self.load()
        self.layout = QVBoxLayout(alignment=Qt.AlignTop)
        self.layout.setMargin(25)
        self.layout.addWidget(FileStorageLocation(self.settings))
        self.setLayout(self.layout)

    def load(self):
        if not os.path.exists(SETTINGS_FILE):
            default_settings = {
                'file_storage_location':
                '{}/Downloads'.format(os.path.expanduser('~')),
            }
            self.save(default_settings)
            return default_settings

        return get_settings()

    def update(self, key, value):
        self.settings[key] = value
        self.save()

    def save(self, settings=None):
        contents = self.settings if settings is None else settings
        with open(SETTINGS_FILE, 'w') as f:
            json.dump(contents, f)
            f.close()
class ModeBasedListView(QWidget):
    def __init__(self, clipboard):
        QWidget.__init__(self)
        self.layout = QVBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setMargin(0)
        self.session_bar = SessionBar(clipboard)
        self.layout.addWidget(self.session_bar)

        self.list_view = ListItemView()
        self.layout.addWidget(self.list_view)

        self.setLayout(self.layout)

    def update(self, prefix, elapsed, fame, fame_per_hour,
               players: PlayerListItem):
        self.session_bar.player_stats.update(elapsed, fame, fame_per_hour)
        self.session_bar.copy_button.update(
            prefix, self.list_view.get_player_list_items(),
            self.session_bar.mode.get_mode(), fame)
        self.list_view.update(players)
        self.session_bar.update()

    def get_mode(self) -> str:
        return self.session_bar.mode.get_mode()
Ejemplo n.º 6
0
class Panel(QWidget):
	header_font = QFont()
	header_font.setBold(True)
	header_font.setPointSize(10)

	def __init__(self, name, script):
		QWidget.__init__(self)

		self.name = name
		self.script = script

		self.layout = QVBoxLayout()
		self.layout.setAlignment(Qt.AlignTop)
		self.layout.setMargin(0)

		self.header = QLabel(self.name)
		self.header.setFont(self.header_font)
		self.header.setAlignment(Qt.AlignLeft)
		self.header.setObjectName("header")
		self.layout.addWidget(self.header)

		self.grid = grid_layout_build(vars(self.script))

		self.layout.addLayout(self.grid)
		self.setLayout(self.layout)
Ejemplo n.º 7
0
    def drawHandInput(self, dictName):
        self.tablesFrames[dictName] = []

        column = QVBoxLayout()
        column.setSpacing(1)
        for _ in range(10):
            cell = QLineEdit()
            cell.setMinimumSize(30, 25)
            cell.setMaximumSize(200, 50)
            column.addWidget(cell)
            self.tablesFrames[dictName].append(cell)

        all = QVBoxLayout()
        temp = QVBoxLayout()
        header = QLabel("Ручной ввод")
        header.setAlignment(Qt.AlignBottom)
        temp.addWidget(header)

        subHeader = QLabel("Оценка\nпослед-тей:")
        subHeader.setMaximumSize(100, 40)

        percent = QLabel("%###")
        percent.setFrameShape(QFrame.WinPanel)
        percent.setFrameShadow(QFrame.Raised)
        self.tablesRatings[dictName] = percent

        all.setSpacing(10)
        all.setMargin(20)
        all.addLayout(temp)
        all.addLayout(column)
        all.addWidget(subHeader)
        all.addWidget(percent)

        return all
Ejemplo n.º 8
0
def new_text_input(parent, title_str, hint_str, only_numbers=False):
    """
    creates input with title
    :param parent:
    :param title_str:
    :param hint_str:
    :param only_numbers:
    :return:
    """
    widget = QWidget(parent)
    widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)

    # layout
    layout = QVBoxLayout()
    layout.setMargin(0)
    layout.setSpacing(2)

    # label
    widget.label_title = QLabel(widget)
    widget.label_title.setText(title_str)
    widget.label_title.setSizePolicy(QSizePolicy.Preferred,
                                     QSizePolicy.Maximum)

    # text edit
    widget.text_edit = LineEdit(widget, hint_str)
    if only_numbers:
        widget.text_edit.setValidator(QIntValidator(0, 100, widget))

    # add to layout
    layout.addWidget(widget.label_title)
    layout.addWidget(widget.text_edit)

    widget.setLayout(layout)

    return widget
Ejemplo n.º 9
0
    def __init__(self, p, title):
        QWidget.__init__(self)
        title = QLabel(title)
        self._frame = QFrame()
        self._lMax = QLabel(str(0))
        self._lMax.setMaximumWidth(35)
        self._lVal = QLabel(str(0))
        self._lVal.setMaximumWidth(35)
        self.setMaximumSize(200, 50)
        llayout = QVBoxLayout()
        llayout.setSpacing(0)
        llayout.setMargin(0)
        llayout.addWidget(title)
        llayout.addWidget(self._lMax)
        llayout.addWidget(self._lVal)
        layout = QHBoxLayout()
        layout.setSpacing(0)
        layout.setMargin(0)
        layout.addWidget(self._frame)
        layout.addLayout(llayout)

        self.setLayout(layout)
        self._history = []
        self._length = 10  # time to display in sec
        self._max = 0.1
        self._min = -0.1
        self._val = 0
        self._maxoflength = 0
        self._periodicity = p  #time period between value in sec
Ejemplo n.º 10
0
    def __init__(self, config):
        """
        Serial Terminal frame

        :param config: application configuration file
        """
        QWidget.__init__(self)

        self.setMinimumSize(QSize(WIN_WIDTH, WIN_HEIGHT))
        self.setMaximumSize(QSize(int(WIN_WIDTH * 1.3), int(WIN_HEIGHT * 1.5)))

        self.setWindowTitle("DigiQt - Serial terminal")

        self.textbox = MyTextBox()  # Create custom text box
        font = QFont()
        font.setFamily(get_font(config))  # Monospaced font
        font.setPointSize(11)
        self.textbox.setFont(font)
        layout = QVBoxLayout()
        layout.setMargin(60)
        layout.addWidget(self.textbox)
        self.setLayout(layout)
        self.text_update.connect(
            self.append_text)  # Connect text update to handler

        self.serth = None  # Terminal thread created by serial controler
        self.sig_terminal_open = None  # Signal pushed by serial controler
Ejemplo n.º 11
0
class Downloads(QWidget):
    def __init__(self):
        super(Downloads, self).__init__()
        self.history = get_download_history()
        self.history.reverse()

        self.layout = QStackedLayout()
        self.layout.setMargin(0)

        self.page_widget = QScrollArea()
        self.page_widget.setWidgetResizable(True)

        widget = QWidget(self.page_widget)
        widget.setMinimumWidth(350)
        self.page_widget.setWidget(widget)

        self.page_layout = QVBoxLayout(widget, alignment=Qt.AlignTop)
        self.page_layout.setMargin(0)
        self.page_layout.setContentsMargins(25, 25, 25, 25)
        self.layout.addWidget(self.page_widget)
        self.layout.setCurrentWidget(self.page_widget)

        if len(self.history) == 0:
            self.history_empty_label = QLabel('No downloads',
                                              alignment=Qt.AlignCenter)
            self.layout.addWidget(self.history_empty_label)
            self.layout.setCurrentWidget(self.history_empty_label)

        for item in self.history:
            self.page_layout.addWidget(DownloadItem(item=item))

        self.setLayout(self.layout)
Ejemplo n.º 12
0
    def _setup_ui(self):
        status_bar = self.statusBar()
        status_bar.setSizeGripEnabled(False)
        status_bar.setContentsMargins(4, 0, 0, 0)
        status_bar.setStyleSheet('QStatusBar::item {border: None;}')
        self._status = QLabel('STATUS')
        status_bar.addWidget(self._status)

        # Create a central widget, give it a layout, and set it up
        central = QWidget(self)
        self.setCentralWidget(central)
        layout = QVBoxLayout()
        layout.setMargin(10)
        central.setLayout(layout)

        ag = ApolloGroup(self, "INTERFACE")
        dsky_sw = ApolloLabeledSwitch(self, "DSKY")
        monitor_sw = ApolloLabeledSwitch(self, "MONITOR", labelwidth=62)
        fdai_sw = ApolloLabeledSwitch(self, "FDAI")

        dsky_sw.switch.setChecked(True)
        monitor_sw.switch.setChecked(True)
        fdai_sw.switch.setChecked(False)
        dsky_sw.switch.stateChanged.connect(self.toggle_dsky)
        monitor_sw.switch.stateChanged.connect(self.toggle_monitor)
        fdai_sw.switch.stateChanged.connect(self.toggle_fdai)

        ag.addWidget(dsky_sw)
        ag.addWidget(monitor_sw)
        ag.addWidget(fdai_sw)

        layout.addWidget(ag)
        layout.setAlignment(ag, Qt.AlignTop | Qt.AlignLeft)
        layout.addStretch()
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        QFrame.__init__(self, parent)

        self.m_mouse_down = False
        self.setFrameShape(QFrame.StyledPanel)

        css = """
        QFrame{
            Background:  #212121;
            color:white;
            font: 12pt "Roboto";
            font-weight:bold;
            }
        """
        self.setStyleSheet(css)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setMouseTracking(True)

        self.m_titleBar = TitleBar()
        self.m_content = QWidget(self)

        vbox = QVBoxLayout(self)
        vbox.addWidget(self.m_titleBar)
        vbox.setMargin(0)
        vbox.setSpacing(0)

        layout = QVBoxLayout(self)
        layout.addWidget(self.m_content)
        layout.setMargin(5)
        layout.setSpacing(0)
        vbox.addLayout(layout)
        self.widgets()
class FilePathButton(QWidget):
    def __init__(self, parent, file_name, file_path, callback):
        super().__init__(parent)
        self.file_path = file_path
        self.callback = callback

        self.v_layout = QVBoxLayout()
        self.v_layout.setSpacing(0)
        self.v_layout.setMargin(0)

        file_icon = QIcon(icon.TABLE_I())
        file_paht_c = Path(file_path)
        file_metadata_path = file_paht_c.get_metadata_path()
        file_metadata_c = None
        if os.path.isfile(file_metadata_path):
            file_metadata_c = MetaData(file_metadata_path, file_paht_c, True)
            if file_metadata_c.metadata["sequential_info"]["is_sequential"]:
                file_icon = QIcon(icon.RELATION_TABLE_I())

        self.btn = QPushButton(file_icon, file_name, self)
        self.btn.clicked.connect(self.send)

        self.v_layout.addWidget(self.btn)
        self.setLayout(self.v_layout)

    def send(self):
        self.callback(self.file_path)
    def _setup_ui(self):
        self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        layout.setAlignment(Qt.AlignTop)
        layout.setSpacing(2)
        layout.setMargin(2)
        layout.addSpacing(20)

        self._alarms = Alarms(self, self._usbif)
        layout.addWidget(self._alarms)

        self._meas = Measurements(self, self._usbif)
        layout.addWidget(self._meas)

        self._core_rope_sim = CoreRopeSim(self, self._usbif)
        layout.addWidget(self._core_rope_sim)
        layout.setAlignment(self._core_rope_sim, Qt.AlignTop)

        self._erasable_mem_sim = ErasableMemSim(self, self._usbif)
        layout.addWidget(self._erasable_mem_sim)
        layout.setAlignment(self._erasable_mem_sim, Qt.AlignTop)

        self._trace = Trace(self, self._usbif)
        layout.addWidget(self._trace)
Ejemplo n.º 16
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.setWindowTitle("AxiGUI")
        self._config_dialog = ConfigDialog()
        self._plot_control = PlotControlWidget()

        # setup toolbar
        self._toolbar = QToolBar()
        self._toolbar.setIconSize(QSize(64, 64))
        load_act = self._toolbar.addAction(QIcon("images/icons_open.png"),
                                           "Load")
        load_act.triggered.connect(lambda: self.load_svg())
        config_act = self._toolbar.addAction(
            QIcon("images/icons_settings.png"), "Config")
        config_act.triggered.connect(lambda: self._config_dialog.exec_())
        self._toolbar.addSeparator()
        self._plot_control.add_actions(self._toolbar)
        empty = QWidget()
        empty.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred))
        self._toolbar.addWidget(empty)
        quit_act = self._toolbar.addAction(QIcon("images/icons_exit.png"),
                                           "Quit")
        quit_act.triggered.connect(lambda: QCoreApplication.quit())

        # setup layout
        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setMargin(0)
        layout.addWidget(self._toolbar)
        layout.addWidget(self._plot_control)
        self.setLayout(layout)
Ejemplo n.º 17
0
    def __init__(self, path=None, list=[], index=0):
        super(ImageViewer, self).__init__()
        self.path = path
        self.index = index
        self.list = list
        self.viewer = PhotoViewer(self)
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        self.viewer.photoClicked.connect(self.photoClicked)

        VBlayout = QVBoxLayout(self)
        VBlayout.addWidget(self.viewer)
        VBlayout.setMargin(0)

        if len(list) > 1:
            btn_layout = QHBoxLayout()
            self.btnBack = QPushButton('<')
            self.btnBack.clicked.connect(self.lastImage)

            self.btnFoward = QPushButton('>')
            self.btnFoward.clicked.connect(self.nextImage)

            btn_layout.addWidget(self.btnBack)
            btn_layout.addWidget(self.btnFoward)

            self.layout().addLayout(btn_layout)

        self.showNormal()
        self.resize(500, 500)
class Folder(QWidget):
    def __init__(self, parent, open_file_call, folder_path):
        super().__init__(parent)
        self.folder_path = folder_path
        self.folder_open = False

        self.setStyleSheet(styles.file_path_button)

        self.main_v_layout = QVBoxLayout()
        self.main_v_layout.setSpacing(2)
        self.main_v_layout.setMargin(0)

        self.files = QWidget(self)
        self.files.hide()
        self.files.setStyleSheet(styles.files_list)
        self.files.setContentsMargins(15, 0, 0, 0)
        self.files_v_layout = QVBoxLayout()

        self.folder_btn = QPushButton(QIcon(icon.FOLDER_I()),
                                      self.folder_path.split(os.path.sep)[-1],
                                      self)
        self.folder_btn.clicked.connect(self.open_folder)

        self.main_v_layout.addWidget(self.folder_btn)

        _list = sorted(os.listdir(self.folder_path))

        for file in _list:
            file_absolute_path = self.folder_path + os.path.sep + file

            if os.path.isdir(file_absolute_path):
                self.files_v_layout.addWidget(
                    Folder(self.files, open_file_call,
                           self.folder_path + os.path.sep + file))
                continue

            if os.path.splitext(file_absolute_path)[1] != '.csv':
                continue
            file_btn = FilePathButton(self.files, file, file_absolute_path,
                                      open_file_call)
            self.files_v_layout.addWidget(file_btn)

        self.files.setLayout(self.files_v_layout)

        self.main_v_layout.addWidget(self.files)

        self.setLayout(self.main_v_layout)

    def open_folder(self):
        self.close() if self.folder_open else self.open()
        self.folder_open = not self.folder_open

    def open(self):
        self.files.show()
        self.folder_btn.setIcon(QIcon(icon.OPENED_FOLDER_I()))

    def close(self):
        self.files.hide()
        self.folder_btn.setIcon(QIcon(icon.FOLDER_I()))
 def _init_layout(self):
     layout = QVBoxLayout()
     layout.setSpacing(0)
     layout.setMargin(0)
     layout.addWidget(self.status)
     layout.addWidget(self.mda, stretch=80)
     layout.addWidget(self.bar, stretch=20)
     self.setLayout(layout)
Ejemplo n.º 20
0
class FormApplicationTitleBar(QtWidgets.QWidget):
    # 定义成员变量和类变量

    # 定义信号
    minButtonClicked = Signal()
    maxButtonClicked = Signal()
    closeButtonClicked = Signal()

    def __init__(self):
        super().__init__()
        self.mainLayout = QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setMargin(0)
        self.titleFrame = QtWidgets.QFrame()
        self.titleFrame.setObjectName("titleFrame")
        self.titleFrame.setContentsMargins(0, 0, 0, 0)
        self.titleBoxLayout = QtWidgets.QHBoxLayout()
        self.titleBoxLayout.setMargin(0)
        self.titleBoxLayout.setContentsMargins(0, 0, 0, 0)

        self.leftSpaceItem = QtWidgets.QSpacerItem(3, 20, QSizePolicy.Fixed)
        self.middleSpaceItem = QtWidgets.QSpacerItem(5, 20,
                                                     QSizePolicy.Expanding)
        self.minButton = QtWidgets.QToolButton()
        self.minButton.setObjectName("minButton")
        self.maxButton = QtWidgets.QToolButton()
        self.maxButton.setObjectName("maxButton")
        self.closeButton = QtWidgets.QToolButton()
        self.closeButton.setObjectName("closeButton")
        self.appIconLabel = QtWidgets.QLabel()
        self.appIconLabel.setFixedSize(QSize(25, 25))
        self.appIconLabel.setScaledContents(True)
        self.appIconLabel.setPixmap(
            QPixmap(':/icon/Resources/icon/icon-music.png'))
        self.titleContextLabel = QtWidgets.QLabel("网络音乐播放器")
        self.titleContextLabel.setObjectName('titleContextLabel')
        self.contextFont = QFont('微软雅黑', 11)
        self.titleContextLabel.setFont(self.contextFont)
        self.rightSpaceItem = QtWidgets.QSpacerItem(5, 20, QSizePolicy.Fixed)
        self.titleBoxLayout.addItem(self.leftSpaceItem)
        self.titleBoxLayout.addWidget(self.appIconLabel)
        self.titleBoxLayout.addWidget(self.titleContextLabel)
        self.titleBoxLayout.addItem(self.middleSpaceItem)
        self.titleBoxLayout.addWidget(self.minButton)
        self.titleBoxLayout.addWidget(self.maxButton)
        self.titleBoxLayout.addWidget(self.closeButton)
        self.titleBoxLayout.addItem(self.rightSpaceItem)
        self.titleBoxLayout.setSpacing(10)
        self.titleFrame.setLayout(self.titleBoxLayout)
        self.mainLayout.addWidget(self.titleFrame)
        self.setLayout(self.mainLayout)

        self.__connectSignalsAndSlots()

    def __connectSignalsAndSlots(self):
        self.minButton.clicked.connect(self.minButtonClicked)
        self.maxButton.clicked.connect(self.maxButtonClicked)
        self.closeButton.clicked.connect(self.closeButtonClicked)
Ejemplo n.º 21
0
 def __init__(self):
     QWidget.__init__(self)
     self.calendar = CalendarWidget()
     layout = QVBoxLayout()
     layout.addWidget(self.calendar)
     layout.setMargin(0)
     layout.setSpacing(0)
     self.setLayout(layout)
     self.resize(EPD_HEIGHT, EPD_WIDTH)
Ejemplo n.º 22
0
class ApolloGroup(QWidget):
    def __init__(self,
                 parent,
                 text,
                 horizontal=True,
                 nframes=1,
                 *args,
                 **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.widgets = []

        self.layout = QVBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setMargin(0)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.heading = ApolloGroupHeading(parent, text)
        self.layout.addWidget(self.heading)
        self.layout.addSpacing(12)

        self.framelayouts = []
        for i in range(nframes):
            f = QFrame(parent)
            self.layout.addWidget(f)
            if horizontal:
                self.framelayouts.append(QHBoxLayout())
            else:
                self.framelayouts.append(QVBoxLayout())
            self.framelayouts[-1].setMargin(0)
            self.framelayouts[-1].setSpacing(10)
            f.setLayout(self.framelayouts[-1])

            if i < nframes - 1:
                self.layout.addSpacing(8)

        self.layout.addStretch()
        self.setLayout(self.layout)

    def addWidget(self, w, frame=0):
        self.widgets.append(w)
        self.framelayouts[frame].addWidget(w)

    def addSpacing(self, spacing, frame=0):
        self.framelayouts[frame].addSpacing(spacing)

    def addStretch(self, frame=0):
        self.framelayouts[frame].addStretch()

    def group(self):
        bg = QButtonGroup(self)
        for w in self.widgets:
            try:
                bg.addButton(w.switch)
            except AttributeError:
                pass
        bg.exclusive()
Ejemplo n.º 23
0
class Widget(QWidget):

    def __init__(self):
        super().__init__()
        self.items = 0

        # Example data
        self._data = {"Water": 24.5, "Electricity": 55.1, "Rent": 850.0,
                      "Supermarket": 230.4, "Internet": 29.99, "Bars": 21.85,
                      "Public transportation": 60.0, "Coffee": 22.45, "Restaurants": 120}

        # Left
        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(["Description", "Price"])
        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)

        # QWidget Layout
        self.layout = QHBoxLayout()

        # self.table_view.setSizePolicy(size)
        self.layout.addWidget(self.table)

        # Set the layout to the QWidget
        self.setLayout(self.layout)

        # Fill example data
        self.fill_table()

        # Right
        self.description = QLineEdit()
        self.price = QLineEdit()
        self.add = QPushButton("Add")
        self.clear = QPushButton("Clear")
        self.quit = QPushButton("Quit")

        self.right = QVBoxLayout()
        self.right.setMargin(10)
        self.right.addWidget(QLabel("Description"))
        self.right.addWidget(self.description)
        self.right.addWidget(QLabel("Price"))
        self.right.addWidget(self.price)
        self.right.addWidget(self.add)
        self.right.addStretch()
        self.right.addWidget(self.clear)
        self.right.addWidget(self.quit)

        self.layout.addLayout(self.right)

    def fill_table(self, data=None):
        data = self._data if not data else data
        for desc, price in data.items():
            self.table.insertRow(self.items)
            self.table.setItem(self.items, 0, QTableWidgetItem(desc))
            self.table.setItem(self.items, 1, QTableWidgetItem(str(price)))
            self.items += 1
Ejemplo n.º 24
0
    def _setup_ui(self):
        self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)

        layout = QHBoxLayout(self)
        self.setLayout(layout)

        # Create a group box for the inhibit switches
        nh_group = QGroupBox('INH', self)
        nh_group.setAlignment(Qt.AlignCenter)
        layout.addWidget(nh_group)
        layout.setAlignment(nh_group, Qt.AlignTop)
        layout.setMargin(1)
        layout.setSpacing(1)

        # Set up a grid layout to hold the labels, switches, and indicators
        nh_layout = QGridLayout(nh_group)
        nh_group.setLayout(nh_layout)
        nh_layout.setMargin(1)
        nh_layout.setSpacing(1)

        # Construct the inhibit indicators and switches
        col = 0
        for switch, msg in INH_SWITCHES.items():
            self._create_inh_control(switch, nh_group, nh_layout, col)
            ind = self._inh_inds[-1]
            self._inh_switches[-1].stateChanged.connect(
                lambda on, ind=ind, msg=msg: self._set_inh(ind, msg, on))
            col += 1

        sl_group = QWidget(self)
        layout.addWidget(sl_group)
        sl_layout = QVBoxLayout(sl_group)
        sl_group.setLayout(sl_layout)
        sl_layout.setMargin(1)
        sl_layout.setSpacing(1)
        sl_layout.addSpacing(4)

        stat_group = QWidget(sl_group)
        sl_layout.addWidget(stat_group)
        stat_layout = QGridLayout(stat_group)
        stat_layout.setMargin(3)
        stat_layout.setSpacing(3)

        col = 0
        for name, label in STATUS_INDS.items():
            self._status_inds[name] = self._create_status_light(
                label, stat_group, stat_layout, col)
            col += 1

        label = QLabel('CONTROL', sl_group)
        font = label.font()
        font.setPointSize(12)
        font.setBold(True)
        label.setFont(font)
        label.setAlignment(Qt.AlignCenter)
        sl_layout.addWidget(label)
Ejemplo n.º 25
0
class Widget(QWidget):
	def __init__(self):
		QWidget.__init__(self)
		
		self.layout = QHBoxLayout() # start 	main panel
		
		self.list = QListWidget()
		self.table = QTableWidget()
		self.table.setColumnCount(3)
		self.table.setHorizontalHeaderLabels(["Track Name", "Artist", "Album"])
		self.right = QVBoxLayout()
		self.right.setMargin(10)
		# self.right.addStretch()

		self.filter_group = QGroupBox("Filters")
		filter_artist = QRadioButton("By Artist")
		filter_genre = QRadioButton("By Genre")
		filter_track = QRadioButton("By Track")
		filter_artist.setChecked(True)
		vbox = QVBoxLayout()
		vbox.addWidget(filter_artist)
		vbox.addWidget(filter_genre)
		vbox.addWidget(filter_track)
		# vbox.addStretch(1)
		self.filter_group.setLayout(vbox)

		self.search_layout = QHBoxLayout()
		self.search_field = QLineEdit()
		self.search_layout.addWidget(QLabel("Search Term"))
		self.search_layout.addWidget(self.search_field)
		self.neg_search_button = QCheckBox("Enable Negative Search")
		
		create_box = QGroupBox("Create Playlist")
		vbox_create_playlist = QVBoxLayout()
		hbox_name = QHBoxLayout()
		self.create_name_field = QLineEdit()
		hbox_name.addWidget(QLabel("Name"))
		hbox_name.addWidget(self.create_name_field)
		self.desc_edit = QPlainTextEdit()
		self.create_button = QPushButton("Create Playlist")
		vbox_create_playlist.addLayout(hbox_name)
		vbox_create_playlist.addWidget(QLabel("Description"))
		vbox_create_playlist.addWidget(self.desc_edit)
		vbox_create_playlist.addWidget(self.create_button)
		create_box.setLayout(vbox_create_playlist)
		
		self.right.addWidget(self.filter_group)
		self.right.addLayout(self.search_layout)	
		self.right.addWidget(self.neg_search_button)
		self.right.addWidget(create_box)

		self.layout.addWidget(self.list)
		self.layout.addWidget(self.table)
		self.layout.addLayout(self.right)

		self.setLayout(self.layout) # end 		main panel
Ejemplo n.º 26
0
    def __set_layout(self):
        """
        Sets this widget's layout
        """
        layout = QVBoxLayout()
        layout.setMargin(0)

        layout.addWidget(self.courses_toolbar)
        layout.addWidget(self.tableview)

        self.setLayout(layout)
Ejemplo n.º 27
0
    def __set_layout(self) -> None:
        """
        Sets this widget's layout
        """
        layout = QVBoxLayout()
        layout.setMargin(0)

        layout.addWidget(self.attributes_toolbar)
        layout.addWidget(self.tableview)

        self.setLayout(layout)
Ejemplo n.º 28
0
    def __init__(self, path, owner):
        QWidget.__init__(self)
        self.path = path
        self.scroll_area = QScrollArea()
        self.num_columns = 3
        self.owner = owner
        # self.checkboxes_widget = QWidget()

        for paper in Index.gPapers:
            if paper['path'] == self.path:
                self.paper = paper

        self.columns = []
        for i in range(self.num_columns):
            layout = QVBoxLayout()
            layout.setSpacing(0)
            layout.setMargin(0)
            self.columns.append(layout)

        self.checkboxes = []
        self.tags_copy = Index.gTags.copy()
        self.tags_copy.sort(key=lambda s: s)

        count = 0
        for tag in self.tags_copy:
            checkbox = QCheckBox(tag)
            self.checkboxes.append(checkbox)
            self.columns[int(
                (self.num_columns * count) / len(self.tags_copy))].addWidget(
                    checkbox)  #add the checkbox to the appropriate column

            if 'tags' in self.paper:
                if tag in self.paper['tags']:
                    checkbox.setChecked(True)

            checkbox.clicked.connect(self.checkbox_click_creator(checkbox))
            count += 1

        # self.checkboxes_widget.setLayout(self.layout)
        # self.scroll_area.setWidget(self.checkboxes_widget)

        self.layout = QHBoxLayout()
        for col in self.columns:
            self.layout.addLayout(col)

        self.scroll_area.setLayout(self.layout)
        self.scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll_area.setWidgetResizable(True)

        self.full_layout = QHBoxLayout()
        self.full_layout.addWidget(self.scroll_area)

        self.setLayout(self.full_layout)
Ejemplo n.º 29
0
class Songlist(QWidget):
    def __init__(self, songlist=None):
        super(Songlist, self).__init__()
        self.songlist = songlist

        self.layout = QVBoxLayout()
        self.layout.setMargin(0)
        self.layout.setSpacing(25)
        for index, song in enumerate(self.songlist):
            self.layout.addWidget(Song(song=song, index=index + 1))
        self.setLayout(self.layout)
Ejemplo n.º 30
0
    def _layout(self):
        self._inner = _FrameInner(parent=self)
        self._buttons = _WindowButtons(parent=self)
        self._buttons.on_minimize.connect(self.on_minimize)
        self._buttons.on_settings.connect(self.on_settings)
        self._buttons.on_exit.connect(self.on_exit)

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setMargin(0)
        self.setLayout(layout)
        layout.addWidget(self._inner)
        self._buttons.show()