def __create_filter_ui(self):
        """ Create filter widgets """
        filter_layout = QHBoxLayout()
        filter_layout.setSpacing(1)
        filter_layout.setContentsMargins(0, 0, 0, 0)

        self.filter_reset_btn = QPushButton()
        icon = QIcon(':/filtersOff.png')
        self.filter_reset_btn.setIcon(icon)
        self.filter_reset_btn.setIconSize(QSize(22, 22))
        self.filter_reset_btn.setFixedSize(24, 24)
        self.filter_reset_btn.setToolTip('Reset filter')
        self.filter_reset_btn.setFlat(True)
        self.filter_reset_btn.clicked.connect(
            partial(self.on_filter_set_text, ''))

        self.filter_line = QLineEdit()
        self.filter_line.setPlaceholderText('Enter filter string here')
        self.filter_line.textChanged.connect(self.on_filter_change_text)

        completer = QCompleter(self)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setModel(QStringListModel([], self))
        self.filter_line.setCompleter(completer)

        filter_layout.addWidget(self.filter_reset_btn)
        filter_layout.addWidget(self.filter_line)

        return filter_layout
示例#2
0
def qbutton_with_arguments(parent, todo, button_display_text, argument_list):
    cWidget = QWidget()
    parent.addWidget(cWidget)
    cWidget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
    cWidget.setContentsMargins(1, 1, 1, 1)
    newframe = QHBoxLayout()
    cWidget.setLayout(newframe)
    newframe.setSpacing(1)
    newframe.setContentsMargins(1, 1, 1, 1)
    qmy_button(newframe, todo, button_display_text)
    for entry in argument_list:
        # entry[0] is the variable, entry[1] is the text to display
        if len(entry) == 2:
            qe = qlabeled_entry(entry[0], entry[1], "top")
            qe.efield.returnPressed.connect(todo)
            
            var_val = entry[0].get()
            if type(var_val) == int:
                qe.efield.setText(str(var_val))
                qe.efield.setMaximumWidth(50)
            else:
                qe.efield.setText(var_val)
                qe.efield.setMaximumWidth(100)
            
            newframe.addWidget(qe)
        else:
            qp = aLabeledPopup(entry[0], entry[1], entry[2], "top")
            newframe.addWidget(qp)
    return
    def __create_filter_ui(self):
        """ Create filter widgets """
        filter_layout = QHBoxLayout()
        filter_layout.setSpacing(1)
        filter_layout.setContentsMargins(0, 0, 0, 0)

        self.filter_reset_btn = QPushButton()
        icon = QIcon(':/filtersOff.png')
        self.filter_reset_btn.setIcon(icon)
        self.filter_reset_btn.setIconSize(QSize(22, 22))
        self.filter_reset_btn.setFixedSize(24, 24)
        self.filter_reset_btn.setToolTip('Reset filter')
        self.filter_reset_btn.setFlat(True)
        self.filter_reset_btn.clicked.connect(
            partial(self.on_filter_set_text, ''))

        self.filter_line = QLineEdit()
        self.filter_line.setPlaceholderText('Enter filter string here')
        self.filter_line.textChanged.connect(self.on_filter_change_text)

        completer = QCompleter(self)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setModel(QStringListModel([], self))
        self.filter_line.setCompleter(completer)

        filter_layout.addWidget(self.filter_reset_btn)
        filter_layout.addWidget(self.filter_line)

        return filter_layout
示例#4
0
文件: gui.py 项目: johnjohnsp1/hrdev
    def __init__(self, plugin, *args):

        QFrame.__init__(self, *args)
        self.plugin = plugin
        self.config_main = self.plugin.config_main
        self.config_theme = self.plugin.config_theme
        self.tools = self.plugin.tools

        self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)

        self.edit = self.PlainTextEdit(self)
        self.number_bar = self.NumberBar(self.config_theme, self.edit)

        hbox = QHBoxLayout(self)
        hbox.setSpacing(0)
        hbox.addWidget(self.number_bar)
        hbox.addWidget(self.edit)

        self.edit.blockCountChanged.connect(self.number_bar.adjust_width)
        self.edit.updateRequest.connect(self.number_bar.update_contents)
        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+S"), self).\
            activated.connect(self.save_file)
        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self).\
            activated.connect(self.show_find)
        return
示例#5
0
 def __init__(self, title, *args, **kwargs ):
     
     QWidget.__init__( self, *args )
     
     self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_loadJoints_%s.txt" % title
     sgCmds.makeFile( self.infoPath )
     
     layout = QVBoxLayout( self ); layout.setContentsMargins(0,0,0,0)
     
     groupBox = QGroupBox( title )
     layout.addWidget( groupBox )
     
     baseLayout = QVBoxLayout()
     groupBox.setLayout( baseLayout )
     
     listWidget = QListWidget()
     
     hl_buttons = QHBoxLayout(); hl_buttons.setSpacing( 5 )
     b_addSelected = QPushButton( "Add Selected" )
     b_clear = QPushButton( "Clear" )
     
     hl_buttons.addWidget( b_addSelected )
     hl_buttons.addWidget( b_clear )
     
     baseLayout.addWidget( listWidget )
     baseLayout.addLayout( hl_buttons )
     
     self.listWidget = listWidget
     
     QtCore.QObject.connect( listWidget, QtCore.SIGNAL( "itemClicked(QListWidgetItem*)" ), self.selectJointFromItem )
     QtCore.QObject.connect( b_addSelected, QtCore.SIGNAL("clicked()"), self.addSelected )
     QtCore.QObject.connect( b_clear, QtCore.SIGNAL( "clicked()" ), self.clearSelected )
     
     self.otherWidget = None        
     self.loadInfo()
    def __init__(self, parent=None, index=None):
        super(PathEditor, self).__init__(parent)

        self.parent = parent
        self.index = index
        self.open_dialog_visible = False

        self.setFocusPolicy(Qt.StrongFocus)

        editor_layout = QHBoxLayout()
        editor_layout.setContentsMargins(0, 0, 0, 0)
        editor_layout.setSpacing(0)

        self.line_edit = LineEditor(self)
        editor_layout.addWidget(self.line_edit)

        self.button = QPushButton('')
        self.button.setIcon(QIcon(':/editor_folder'))
        self.button.setFixedSize(18, 17)
        self.button.setToolTip('Select a texture')
        self.button.setStatusTip('Select a texture')
        self.button.clicked.connect(self.select_file)
        editor_layout.addWidget(self.button)

        self.setFocusProxy(self.line_edit)
        self.setLayout(editor_layout)
示例#7
0
 def layoutWidgets(self):
     layout = QVBoxLayout()
     entryLayout = QHBoxLayout()
     entryLayout.setSpacing(0)
     entryLayout.addWidget(self.entryLabel)
     entryLayout.addWidget(self.termLabel)
     entryLayout.addStretch()
     layout.addLayout(entryLayout)
     eidLayout = QVBoxLayout()
     eidLayout.addWidget(self.moveToTopRadioButton)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.grandParentRadioButton)
     hbox.addWidget(self.grandParentLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.filteredRadioButton)
     hbox.addWidget(self.filteredLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.circledRadioButton)
     hbox.addWidget(self.circledLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.recentRadioButton)
     hbox.addWidget(self.recentComboBox, 1)
     eidLayout.addLayout(hbox)
     eidLayout.addStretch()
     self.eidGroup.setLayout(eidLayout)
     layout.addWidget(self.eidGroup)
     layout.addWidget(self.buttonBox)
     self.setLayout(layout)
示例#8
0
    def __init__(self, *args, **kwargs):

        super(Widget_objectList, self).__init__(*args, **kwargs)
        self.installEventFilter(self)
        mainLayout = QVBoxLayout(self)

        treeWidget = QTreeWidget()
        treeWidget.setColumnCount(2)
        headerItem = treeWidget.headerItem()
        headerItem.setText(0, "Target Node")
        headerItem.setText(1, "Attribute Name")
        treeWidget.setRootIsDecorated(False)
        treeWidget.setStyleSheet(
            "QTreeWidget::item { border-left: 1px solid gray;border-bottom: 1px solid gray; padding: 3px}\
                                 QTreeWidget{ font-size:13px;}")
        treeWidget.header().setStyleSheet("font-size:12px;")

        w_buttons = QWidget()
        lay_buttons = QHBoxLayout(w_buttons)
        lay_buttons.setContentsMargins(0, 0, 0, 0)
        lay_buttons.setSpacing(0)
        button_load = QPushButton("Load List")
        button_load.setStyleSheet("font:14px;")
        lay_buttons.addWidget(button_load)

        mainLayout.addWidget(treeWidget)
        mainLayout.addWidget(w_buttons)

        self.treeWidget = treeWidget
        QtCore.QObject.connect(
            treeWidget, QtCore.SIGNAL("itemChanged(QTreeWidgetItem * , int )"),
            self.writeData)
        QtCore.QObject.connect(button_load, QtCore.SIGNAL("clicked()"),
                               self.cmd_loadList)
示例#9
0
    def __init__(self, parent=None, index=None):
        super(PathEditor, self).__init__(parent)

        self.parent = parent
        self.index = index
        self.open_dialog_visible = False

        self.setFocusPolicy(Qt.StrongFocus)

        editor_layout = QHBoxLayout()
        editor_layout.setContentsMargins(0, 0, 0, 0)
        editor_layout.setSpacing(0)

        self.line_edit = LineEditor(self)
        editor_layout.addWidget(self.line_edit)

        self.button = QPushButton('')
        self.button.setIcon(QIcon(':/editor_folder'))
        self.button.setFixedSize(18, 17)
        self.button.setToolTip('Select a texture')
        self.button.setStatusTip('Select a texture')
        self.button.clicked.connect(self.select_file)
        editor_layout.addWidget(self.button)

        self.setFocusProxy(self.line_edit)
        self.setLayout(editor_layout)
示例#10
0
文件: gui.py 项目: 453483289/hrdev
    def __init__(self, plugin, *args):

        QFrame.__init__(self, *args)
        self.plugin = plugin
        self.config_main = self.plugin.config_main
        self.config_theme = self.plugin.config_theme
        self.tools = self.plugin.tools
        self.lvars = self.plugin.lvars

        self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)

        self.edit = self.PlainTextEdit(self)
        self.number_bar = self.NumberBar(self.config_theme, self.edit)

        hbox = QHBoxLayout(self)
        hbox.setSpacing(0)
        hbox.addWidget(self.number_bar)
        hbox.addWidget(self.edit)

        self.edit.blockCountChanged.connect(self.number_bar.adjust_width)
        self.edit.updateRequest.connect(self.number_bar.update_contents)
        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+S"), self).\
            activated.connect(self.save_file)
        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self).\
            activated.connect(self.show_find)
        return
示例#11
0
class PluginDialog(QWidget):
    def __init__(self, pluginManager):
        super(PluginDialog, self).__init__()

        self.view = PluginView(pluginManager, self)

        self.vbLayout = QVBoxLayout(self)
        self.vbLayout.setContentsMargins(0, 0, 0, 0)
        self.vbLayout.setSpacing(0)
        self.vbLayout.addWidget(self.view)

        self.hbLayout = QHBoxLayout()
        self.vbLayout.addLayout(self.hbLayout)
        self.hbLayout.setContentsMargins(0, 0, 0, 0)
        self.hbLayout.setSpacing(6)

        self.detailsButton = QPushButton("Details", self)
        self.errorDetailsButton = QPushButton("Error Details", self)
        self.detailsButton.setEnabled(False)
        self.errorDetailsButton.setEnabled(False)

        self.hbLayout.addWidget(self.detailsButton)
        self.hbLayout.addWidget(self.errorDetailsButton)
        self.hbLayout.addStretch(5)

        self.resize(650, 300)
        self.setWindowTitle("Installed Plugins")

        self.view.currentPluginChanged.connect(self.updateButtons)
        self.view.pluginActivated.connect(self.openDetails)
        self.detailsButton.clicked.connect(self.openDetails)
        self.errorDetailsButton.clicked.connect(self.openErrorDetails)

    @Slot()
    def updateButtons(self):
        # todo
        pass

    @Slot()
    def openDetails(self):
        # todo
        pass

    @Slot()
    def openDetails(self, spec):
        # todo
        print("TODO open details")
        pass

    @Slot()
    def openErrorDetails(self):
        # todo
        pass
示例#12
0
 def layoutWidgets(self):
     layout = QHBoxLayout()
     layout.addWidget(self.pane, 1)
     vbox = QVBoxLayout()
     vbox.addWidget(self.scrollbar)
     vbox.addWidget(self.square)
     vbox.setSpacing(0)
     vbox.setContentsMargins(0, 0, 0, 0)
     layout.addLayout(vbox)
     layout.setSpacing(0)
     layout.setContentsMargins(5, 5, 5, 5)
     self.setLayout(layout)
示例#13
0
    def new_tab(self):
        """Open new tab."""
        tasklist = QTreeView()
        tasklist.hide()
        tasklist.setObjectName('taskList')
        tasklist.setMinimumWidth(100)
        tasklist.setMaximumWidth(250)

        new_tab = QWebView()
        new_tab.setObjectName('webView')

        inspector = QWebInspector(self)
        inspector.setObjectName('webInspector')
        inspector.hide()

        page_layout = QVBoxLayout()
        page_layout.setSpacing(0)
        page_layout.setContentsMargins(0, 0, 0, 0)
        page_layout.addWidget(new_tab)
        page_layout.addWidget(inspector)
        page_widget = QFrame()
        page_widget.setObjectName('pageWidget')
        page_widget.setLayout(page_layout)

        complete_tab_layout = QHBoxLayout()
        complete_tab_layout.setSpacing(0)
        complete_tab_layout.setContentsMargins(0, 0, 0, 0)
        complete_tab_layout.addWidget(tasklist)
        complete_tab_layout.addWidget(page_widget)
        complete_tab_widget = QFrame()
        complete_tab_widget.setLayout(complete_tab_layout)

        new_tab.load(QUrl(self.startpage))
        self.tabs.setUpdatesEnabled(False)
        if self.new_tab_behavior == "insert":
            self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                    unicode(new_tab.title()))
        elif self.new_tab_behavior == "append":
            self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
        self.tabs.setCurrentWidget(complete_tab_widget)
        self.tabs.setTabText(self.tabs.currentIndex(),
                             unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
        self.tabs.setUpdatesEnabled(True)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        new_tab.titleChanged.connect(self.change_tab)
        new_tab.urlChanged.connect(self.change_tab)
        new_tab.loadStarted.connect(self.load_start)
        new_tab.loadFinished.connect(self.load_finish)
        new_tab.loadProgress.connect(self.pbar.setValue)
        new_tab.page().linkHovered.connect(self.linkHover)
        inspector.setPage(new_tab.page())
示例#14
0
class SensorDisplay(QWidget):
  def __init__(self, name=None):
    super(SensorDisplay, self).__init__()
    self.graph = pg.PlotWidget(name=name)
    self.plots = []
    title = QLabel(name)
    title.setStyleSheet('color: white; background-color: black')
    title.setAlignment(Qt.AlignCenter)
    self.setFixedHeight(150)

    mainLayout = QVBoxLayout()
    mainLayout.setContentsMargins(0,0,0,0)
    mainLayout.setSpacing(0)
    self.setLayout(mainLayout)
    self.dataLayout = QHBoxLayout()
    self.dataLayout.setContentsMargins(0,0,0,0)
    self.dataLayout.setSpacing(0)

    mainLayout.addWidget(title)
    mainLayout.addWidget(self.graph)
    mainLayout.addLayout(self.dataLayout)

  # ---------------------------------------------------------------------------------------
  def addPlot(self, fillLevelIn, brushIn, penIn, dataType='float', dataName=None):
    data = np.array([0], dtype=dataType)

    plot = self.graph.plot(fillLevel=fillLevelIn, brush=brushIn, pen=penIn)

    dataWidget = QLabel(dataName)
    dataWidget.dataName = dataName
    dataWidget.setStyleSheet('color: rgb' + str(penIn) + '; background-color: black')

    dataWidget.setAlignment(Qt.AlignCenter)
    self.dataLayout.addWidget(dataWidget)

    self.plots.append({'plot':plot, 'data':data, 'widget':dataWidget})

  # ---------------------------------------------------------------------------------------
  def update(self, dataList):
    for i in range(len(dataList)):
      self.plots[i]['data'] = np.append(self.plots[i]['data'], dataList[i]) 
      self.plots[i]['plot'].setData(self.plots[i]['data'])

      dataName = self.plots[i]['widget'].dataName
      self.plots[i]['widget'].setText(dataName + ' ' + str(dataList[i]))

    if len(self.plots[0]['data']) > 200:
      for plot in self.plots:
        plot['data'] = plot['data'][1:]
示例#15
0
    def _dispose_items(self):
        """ Disposes of each current list item.
        """
        layout = self.layout()
        if not layout:
            layout = QHBoxLayout()
            layout.setSpacing(10)
            self.setLayout(layout)
            return

        child = layout.takeAt(0)
        while child is not None:
            control = child.widget()
            if control is not None:
                control.deleteLater()
            child = layout.takeAt(0)
        del child
示例#16
0
    def __init__(self):
        QWidget.__init__(self)

        self.title = u"Web对象管理"

        # Page
        _page = PageContainer()

        # Window
        _window = ViewWindow()

        # Widget
        _widget = WidgetContainer()

        # 页面 tab
        _tab = QTabWidget()
        _tab.addTab(_page, _page.title)
        _tab.addTab(_window, _window.title)
        _tab.addTab(_widget, _widget.title)

        _tab.setTabPosition(QTabWidget.West)
        _tab.setStyleSheet(get_theme("TabViewWeb"))

        # 测试区
        self.__test = WidgetTest()
        self.__test.setStyleSheet(get_theme("TestWidget"))

        # 主layout
        _layout = QHBoxLayout()
        _layout.addWidget(_tab)
        _layout.addWidget(self.__test)

        _layout.setStretch(0, 5)
        _layout.setStretch(1, 1)

        _layout.setContentsMargins(0, 0, 0, 0)
        _layout.setSpacing(0)

        self.setLayout(_layout)

        # 信号
        _page.sig_selected.connect(self.set_page)
        _widget.sig_selected.connect(self.set_widget)
        self.__test.sig_exec.connect(self.send)
示例#17
0
    def __init__(self, *args, **kwrgs):

        existing_widgets = Window.mayaWin.findChildren(QDialog,
                                                       Window.objectName)
        if existing_widgets: map(lambda x: x.deleteLater(), existing_widgets)

        super(Window, self).__init__(*args, **kwrgs)
        self.installEventFilter(self)
        self.setObjectName(Window.objectName)
        self.setWindowTitle(Window.title)

        mainLayout = QVBoxLayout(self)
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(0)

        w_controller = Widget_Controller()
        w_separator1 = Widget_Separator()
        w_objectList = Widget_objectList()
        w_separator2 = Widget_Separator()
        w_connectionType = Widget_ConnectionType()
        w_buttons = QWidget()
        w_buttons.setStyleSheet("font:14px")
        lay_buttons = QHBoxLayout(w_buttons)
        lay_buttons.setSpacing(0)
        button_connect = QPushButton("CONNECT")
        button_close = QPushButton("CLOSE")
        lay_buttons.addWidget(button_connect)
        lay_buttons.addWidget(button_close)

        mainLayout.addWidget(w_controller)
        mainLayout.addWidget(w_separator1)
        mainLayout.addWidget(w_objectList)
        mainLayout.addWidget(w_separator2)
        mainLayout.addWidget(w_connectionType)
        mainLayout.addWidget(w_buttons)
        self.resize(Window.defaultWidth, Window.defaultHeight)
        self.load_shapeInfo(Window.path_uiInfo)

        button_connect.clicked.connect(self.cmd_connect)
        button_close.clicked.connect(self.deleteLater)

        self.w_controller = w_controller
        self.w_objectList = w_objectList
        self.w_connectionType = w_connectionType
class ConsoleDialog(QtGui.QDialog):
    def __init__(self, stream=None):
        QtGui.QDialog.__init__(self)

        self.stream = stream
        self.setWindowTitle('Console Messages')
        self.layout = QHBoxLayout(self)
        self.layout.setSpacing(6)
        self.layout.setContentsMargins(3, 3, 3, 3)
        self.edit = QTextEdit(self)
        self.edit.setReadOnly(True)
        self.layout.addWidget(self.edit)
        self.resize(450, 250)

    def write(self, msg):
        self.edit.moveCursor(QtGui.QTextCursor.End)
        self.edit.insertPlainText(msg)
        if self.stream:
            self.stream.write(msg)
示例#19
0
    def __init__(self, *args, **kwargs):

        super(Widget_connectionList, self).__init__(*args, **kwargs)
        self.installEventFilter(self)
        mainLayout = QVBoxLayout(self)
        mainLayout.setContentsMargins(5, 5, 5, 5)
        mainLayout.setSpacing(0)

        treeWidget = QTreeWidget()
        treeWidget.setColumnCount(3)
        headerItem = treeWidget.headerItem()
        headerItem.setText(0, "Attribute")
        headerItem.setText(1, "Target Node")
        headerItem.setText(2, "Target Attr")
        treeWidget.setRootIsDecorated(False)
        self.treeWidget = treeWidget

        treeWidget.setStyleSheet(
            "QTreeWidget::item { border-bottom: 1px solid gray; padding:1px}\
                                         QTreeWidget{ font-size:13px;}")
        treeWidget.header().setStyleSheet("font-size:12px;")

        w_buttons = QWidget()
        lay_buttons = QHBoxLayout(w_buttons)
        lay_buttons.setContentsMargins(0, 0, 0, 0)
        lay_buttons.setSpacing(5)
        button_add = QPushButton("Add Line")
        button_remove = QPushButton("Remove Line")
        lay_buttons.addWidget(button_add)
        lay_buttons.addWidget(button_remove)

        mainLayout.addWidget(treeWidget)
        mainLayout.addWidget(w_buttons)
        button_add.clicked.connect(self.cmd_addLine)
        button_remove.clicked.connect(self.cmd_removeLine)

        treeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        QtCore.QObject.connect(
            treeWidget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
            self.loadContextMenu)
        self.treeWidget = treeWidget
        self.readData()
示例#20
0
    def __init__(self, *args, **kwargs):
        super(Widget_ConnectionType, self).__init__(*args, **kwargs)
        self.installEventFilter(self)
        mainLayout = QVBoxLayout(self)
        mainLayout.setSpacing(0)

        self.setStyleSheet("font-size:12px;")
        w_comboBox = QWidget()
        lay_comboBox = QHBoxLayout(w_comboBox)
        lay_comboBox.setContentsMargins(5, 5, 5, 5)
        lay_comboBox.setSpacing(0)
        label = QLabel("Connection Type : ")
        comboBox = QComboBox()
        comboBox.setStyleSheet("padding:2px; padding-left:5px")
        comboBox.addItem("Long Type")
        comboBox.addItem("Enum Type")
        lay_comboBox.addWidget(label)
        lay_comboBox.addWidget(comboBox)

        w_enumAttrName = QWidget()
        lay_enumAttrName = QHBoxLayout(w_enumAttrName)
        lay_enumAttrName.setContentsMargins(5, 5, 5, 5)
        lay_enumAttrName.setSpacing(0)
        label_enumName = QLabel("Enum Attribute Name :  ")
        lineEdit = QLineEdit()
        lineEdit.setStyleSheet("padding:2px")
        lay_enumAttrName.addWidget(label_enumName)
        lay_enumAttrName.addWidget(lineEdit)
        w_enumAttrName.setEnabled(False)

        mainLayout.addWidget(w_comboBox)
        mainLayout.addWidget(w_enumAttrName)

        self.comboBox = comboBox
        self.w_enumAttrName = w_enumAttrName
        self.lineEdit = lineEdit
        self.comboBox.currentIndexChanged.connect(self.cmd_attrTypeCondition)
        self.readData()

        lineEdit.textEdited.connect(self.writeData)
        comboBox.currentIndexChanged.connect(self.writeData)
        self.readData()
示例#21
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)
示例#22
0
文件: home.py 项目: FrostyX/octopy
	def display(self):
		layout = QHBoxLayout()
		layout.setSpacing(10)

		# Left panel - repositories
		qlistWidget = QListWidget()
		for repo in self.args.user.repositories():
			qlistWidget.addItem(repo.name)
		layout.addWidget (qlistWidget)


		# Middle panel - commits
		commitsLabel = QLabel("There will be the commits")
		layout.addWidget (commitsLabel)

		# Something
		somethingLabel = QLabel("There will be something")
		layout.addWidget (somethingLabel)

		self.setLayout(layout)
		self.show()
示例#23
0
    def initialize(self):
        color1 = self.data_singleton.primary_color
        color2 = self.data_singleton.secondary_color

        self._primary_color_chooser = ColorChooserWidget(color1)
        self._secondary_color_chooser = ColorChooserWidget(color2)

        self._primary_color_chooser.send_color.connect(self.set_primary_color)
        self._secondary_color_chooser.send_color.connect(self.set_secondary_color)

        layout = QHBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._primary_color_chooser)
        layout.addWidget(self._secondary_color_chooser)
        layout.addStretch()

        self._widget = QWidget()
        self._widget.setLayout(layout)

        self.mw.ui.generalToolBar.addWidget(self._widget)
示例#24
0
 def __init__(self, display_text, todo, arg_dict, help_instance = None, max_field_size = None):
     super(qButtonWithArgumentsClass, self).__init__()
     self.todo = todo
     self.setContentsMargins(1, 1, 1, 1)
     newframe = QHBoxLayout()
     self.setLayout(newframe)
     newframe.setSpacing(1)
     newframe.setContentsMargins(1, 1, 1, 1)
     
     new_but = QPushButton(display_text)
     new_but.setContentsMargins(1, 1, 1, 1)
     new_but.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     new_but.setFont(regular_font)
     new_but.setAutoDefault(False)
     new_but.setDefault(False)
     newframe.addWidget(new_but)
     new_but.clicked.connect(self.doit)
     self.arg_hotfields = []
     for k in sorted(arg_dict.keys()):
         if isinstance(arg_dict[k], list):
             the_list = arg_dict[k]
             if len(the_list) == 0:
                 qe = qHotField(k, str, "", the_list, pos = "top", max_size = max_field_size)
             else:
                 qe = qHotField(k, type(arg_dict[k][0]), arg_dict[k][0], the_list, pos = "top", max_size = max_field_size)
         else:
             qe = qHotField(k, type(arg_dict[k]), arg_dict[k], pos = "top", max_size = max_field_size)
         newframe.addWidget(qe)
         newframe.setAlignment(qe, QtCore.Qt.AlignLeft)
         self.arg_hotfields.append(qe)
     newframe.addStretch()
     if hasattr(todo, "help_text"):
         if (help_instance == None):
             print "No help instance specified."
         else:
             help_button_widget = help_instance.create_button(display_text, todo.help_text)
             newframe.addWidget(help_button_widget)
             QtGui.QToolTip.setFont(regular_font)
             self.setToolTip(todo.help_text)
示例#25
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)
示例#26
0
    def initialize(self):
        color1 = self.data_singleton.primary_color
        color2 = self.data_singleton.secondary_color

        self._primary_color_chooser = ColorChooserWidget(color1)
        self._secondary_color_chooser = ColorChooserWidget(color2)

        self._primary_color_chooser.send_color.connect(self.set_primary_color)
        self._secondary_color_chooser.send_color.connect(
            self.set_secondary_color)

        layout = QHBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._primary_color_chooser)
        layout.addWidget(self._secondary_color_chooser)
        layout.addStretch()

        self._widget = QWidget()
        self._widget.setLayout(layout)

        self.mw.ui.generalToolBar.addWidget(self._widget)
示例#27
0
    def __init__(self, *args, **kwargs):

        super(Widget_connectionElement, self).__init__(*args, **kwargs)
        self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable
                      | QtCore.Qt.ItemIsDragEnabled
                      | QtCore.Qt.ItemIsDropEnabled)

        lineEdit_attrName = QLineEdit()

        w_targetObject = QWidget(self.treeWidget())
        lay_targetObject = QHBoxLayout(w_targetObject)
        lay_targetObject.setContentsMargins(0, 0, 0, 0)
        lay_targetObject.setSpacing(0)
        lineEdit_targetObject = QLineEdit()
        button_targetObject = QPushButton("Load")
        lay_targetObject.addWidget(lineEdit_targetObject)
        lay_targetObject.addWidget(button_targetObject)

        comboBox_targetAttr = QComboBox(self.treeWidget())
        comboBox_targetAttr.addItem("rotateX")
        comboBox_targetAttr.addItem("rotateY")
        comboBox_targetAttr.addItem("rotateZ")
        comboBox_targetAttr.addItem("rotateX(+)")
        comboBox_targetAttr.addItem("rotateY(+)")
        comboBox_targetAttr.addItem("rotateZ(+)")
        comboBox_targetAttr.addItem("rotateX(-)")
        comboBox_targetAttr.addItem("rotateY(-)")
        comboBox_targetAttr.addItem("rotateZ(-)")
        self.comboBox = comboBox_targetAttr
        self.lineEdit_targetObject = lineEdit_targetObject
        self.lineEdit_attrName = lineEdit_attrName

        self.treeWidget().setItemWidget(self, 0, lineEdit_attrName)
        self.treeWidget().setItemWidget(self, 1, w_targetObject)
        self.treeWidget().setItemWidget(self, 2, comboBox_targetAttr)
        button_targetObject.clicked.connect(self.loadTargetObject)
        comboBox_targetAttr.currentIndexChanged.connect(
            self.treeWidget().parentWidget().writeData)
示例#28
0
    def __init__(self, *args, **kwargs ):
        
        self.uiInfoPath = Window.infoBaseDir + '/Widget_mainController.json'
        
        QWidget.__init__( self, *args, **kwargs )
        mainLayout = QHBoxLayout( self ); mainLayout.setContentsMargins(0,0,0,0)
        mainLayout.setSpacing( 5 )
        
        label = QLabel( "Main Ctl : " )
        lineEdit = QLineEdit()
        button = QPushButton( "Load" )
        
        mainLayout.addWidget( label )
        mainLayout.addWidget( lineEdit )
        mainLayout.addWidget( button )
        
        QtCore.QObject.connect( button, QtCore.SIGNAL("clicked()"), self.loadCtl )

        self.lineEdit = lineEdit
        
        data = BaseCommands.readData( self.uiInfoPath )
        if data.has_key( 'lineEdit' ):
            self.lineEdit.setText( data['lineEdit'] )
示例#29
0
class FileSelector(QWidget):
    def __init__(self, var_name, default_file, project_root_dir = None, help_instance=None):
        QWidget.__init__(self)
        self.project_root_dir = project_root_dir
        self.my_layout = QHBoxLayout()
        self.setLayout(self.my_layout)
        self.var_name = var_name
        self.current_value = default_file
        self.full_path = project_root_dir + default_file
        self.my_layout.setContentsMargins(1, 1, 1, 1)
        self.my_layout.setSpacing(3)

        self.my_but = QPushButton(os.path.basename(remove_trailing_slash(default_file)))
        self.my_but.setFont(regular_small_font)
        self.my_but.setStyleSheet("text-align: left")
        self.my_but.clicked.connect(self.set_file)
        self.my_layout.addWidget(self.my_but)

        my_label = QLabel(var_name)
        my_label.setFont(regular_small_font)
        self.my_layout.addWidget(my_label)

    def set_file(self):
        directions = "Select a file for " + self.var_name
        new_value = QFileDialog.getOpenFileName(self, directions, dir=os.path.dirname(self.full_path))[0]
        new_value = re.sub(self.project_root_dir, "", new_value)
        self.set_myvalue(new_value)

    def get_myvalue(self):
        return self.current_value

    def set_myvalue(self, new_value):
        if new_value != "":
            self.current_value = new_value
            self.my_but.setText(os.path.basename(remove_trailing_slash(self.current_value)))

    value = property(get_myvalue, set_myvalue)
示例#30
0
    def __init__(self, parent, *args, **kw):
        super(_FilterTableView, self).__init__(*args, **kw)
        layout = QVBoxLayout()
        # layout.setSpacing(1)
        self.table = table = _myTableView(parent)

        hl = QHBoxLayout()
        hl.setSpacing(10)

        self.button = button = QPushButton()
        button.setIcon(icon('delete').create_icon())
        button.setEnabled(False)
        button.setFlat(True)
        button.setSizePolicy(QSizePolicy.Fixed,
                             QSizePolicy.Fixed)
        button.setFixedWidth(25)

        self.text = text = QLineEdit()
        self.cb = cb = QCheckBox()


        text.setEnabled(False)
        button.setEnabled(False)
        table.setEnabled(False)
        # cb.setSizePolicy(QSizePolicy.Fixed,
                         # QSizePolicy.Fixed)
        # cb.setFixedWidth(20)
        # cb.setFixedHeight(20)

        hl.addWidget(cb)
        hl.addWidget(text)
        hl.addWidget(button)
        # hl.addStretch()
        layout.addLayout(hl)
        layout.addWidget(table)
        layout.setSpacing(1)
        self.setLayout(layout)
示例#31
0
 def __init__(self, display_text, todo, arg_dict, help_instance = None):
     super(qOldButtonWithArgumentsClass, self).__init__()
     self.todo = todo
     self.arg_dict = arg_dict
     # self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     self.setContentsMargins(1, 1, 1, 1)
     newframe = QHBoxLayout()
     self.setLayout(newframe)
     newframe.setSpacing(1)
     newframe.setContentsMargins(1, 1, 1, 1)
     
     new_but = QPushButton(display_text)
     new_but.setContentsMargins(1, 1, 1, 1)
     new_but.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     new_but.setFont(QFont('SansSerif', 12))
     new_but.setAutoDefault(False)
     new_but.setDefault(False)
     newframe.addWidget(new_but)
     new_but.clicked.connect(self.doit)
     for k in sorted(arg_dict.keys()):
         if isinstance(self.arg_dict[k], list):
             the_list = self.arg_dict[k]
             self.arg_dict[k] = ""
             qe = qLabeledPopup(k, self.arg_dict, the_list, "top")
         elif isinstance(self.arg_dict[k], bool):
             qe = qLabeledCheck(k, self.arg_dict, "top")
         else:
             qe = qLabeledEntry(k, self.arg_dict,  "top")
         newframe.addWidget(qe)
     newframe.addStretch()
     if hasattr(todo, "help_text"):
         if (help_instance == None):
             print "No help instance specified."
         else:
             help_button_widget = help_instance.create_button(display_text, todo.help_text)
             newframe.addWidget(help_button_widget)
示例#32
0
    def __init__(self, parent, *args, **kw):
        super(QDiffEdit, self).__init__(*args, **kw)
        self.left = LinkedTextEdit()
        self.left.orientation = 'left'
        self.left.setReadOnly(True)

        self.right = LinkedTextEdit()
        self.right.orientation = 'right'
        self.right.setReadOnly(True)

        self.connector = QDiffConnector()

        self.left.linked_widget = self.right
        self.right.linked_widget = self.left
        self.left.connector = self.connector
        self.right.connector = self.connector

        layout = QHBoxLayout()

        layout.setSpacing(0)
        layout.addWidget(self.left)
        layout.addWidget(self.connector)
        layout.addWidget(self.right)
        self.setLayout(layout)
示例#33
0
    def __init__(self, parent, *args, **kw):
        super(QDiffEdit, self).__init__(*args, **kw)
        self.left = LinkedTextEdit()
        self.left.orientation = 'left'
        self.left.setReadOnly(True)

        self.right = LinkedTextEdit()
        self.right.orientation = 'right'
        self.right.setReadOnly(True)

        self.connector = QDiffConnector()

        self.left.linked_widget = self.right
        self.right.linked_widget = self.left
        self.left.connector = self.connector
        self.right.connector = self.connector

        layout = QHBoxLayout()

        layout.setSpacing(0)
        layout.addWidget(self.left)
        layout.addWidget(self.connector)
        layout.addWidget(self.right)
        self.setLayout(layout)
示例#34
0
 def __init__(self, *args, **kwargs ):
     
     QDialog.__init__( self, *args, **kwargs )
     self.installEventFilter( self )
     self.setWindowTitle( Window.title )
 
     mainLayout = QVBoxLayout( self )
     
     sep1 = QFrame();sep1.setFrameShape(QFrame.HLine)
     sep2 = QFrame();sep2.setFrameShape(QFrame.HLine)
     sep3 = QFrame();sep3.setFrameShape(QFrame.HLine)
     
     hl_loadVtx = QHBoxLayout(); hl_loadVtx.setSpacing(5)
     w_loadVtx_src  = Widget_LoadVertex( title="Source Root Vertex" )
     w_loadVtx_trg  = Widget_LoadVertex( title="Target Root Vertex" )
     hl_loadVtx.addWidget( w_loadVtx_src )
     hl_loadVtx.addWidget( w_loadVtx_trg )
     
     hl_loadJoints = QHBoxLayout(); hl_loadJoints.setSpacing(5)
     w_loadJoints_src = Widget_loadJoints("Source Joints")
     w_loadJoints_trg = Widget_loadJoints("Target Joints")
     w_loadJoints_src.otherWidget = w_loadJoints_trg;w_loadJoints_trg.otherWidget = w_loadJoints_src;
     hl_loadJoints.addWidget( w_loadJoints_src )
     hl_loadJoints.addWidget( w_loadJoints_trg )
     
     w_selectionGrow = Widget_SelectionGrow()
     
     hl_select = QHBoxLayout(); hl_select.setSpacing(5)
     b_selectSrc = QPushButton( "Select Source Vertices" )
     b_selectTrg = QPushButton( "Select Target Vertices" )
     hl_select.addWidget( b_selectSrc )
     hl_select.addWidget( b_selectTrg )
     
     b_copyWeight = QPushButton( "Copy Weight" )
     
     mainLayout.addLayout( hl_loadVtx )
     mainLayout.addWidget( sep1 )
     mainLayout.addLayout( hl_loadJoints )
     mainLayout.addWidget( sep2 )
     mainLayout.addWidget( w_selectionGrow )
     mainLayout.addLayout( hl_select )
     mainLayout.addWidget( sep3 )
     mainLayout.addWidget( b_copyWeight )
     
     self.resize( Window.defaultWidth, Window.defaultHeight )
     
     self.li_sourceVertex = w_loadVtx_src.lineEdit
     self.li_targetVertex = w_loadVtx_trg.lineEdit
     self.li_numGrow      = w_selectionGrow.lineEdit
     self.lw_srcJoints    = w_loadJoints_src.listWidget
     self.lw_trgJoints    = w_loadJoints_trg.listWidget
     
     QtCore.QObject.connect( b_selectSrc,  QtCore.SIGNAL( "clicked()" ), self.selectSourceVertices )
     QtCore.QObject.connect( b_selectTrg,  QtCore.SIGNAL( "clicked()" ), self.selectTargetVertices )
     QtCore.QObject.connect( b_copyWeight, QtCore.SIGNAL( 'clicked()' ), self.copyWeight )
示例#35
0
 def layoutWidgets(self):
     layout = QVBoxLayout()
     whichLayout = QHBoxLayout()
     whichLayout.addWidget(self.seeRadioButton)
     whichLayout.addWidget(self.alsoRadioButton)
     whichLayout.addStretch()
     self.whichGroup.setLayout(whichLayout)
     layout.addWidget(self.whichGroup)
     entryLayout = QHBoxLayout()
     entryLayout.setSpacing(0)
     entryLayout.addWidget(self.entry1Label)
     entryLayout.addWidget(self.termLabel)
     entryLayout.addWidget(self.entry2Label)
     entryLayout.addStretch()
     layout.addLayout(entryLayout)
     eidLayout = QVBoxLayout()
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.filteredRadioButton)
     hbox.addWidget(self.filteredLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.circledRadioButton)
     hbox.addWidget(self.circledLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.recentRadioButton)
     hbox.addWidget(self.recentComboBox, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.addWidget(self.groupRadioButton)
     hbox.addWidget(self.groupComboBox, 1)
     eidLayout.addLayout(hbox)
     grid = QGridLayout()
     grid.addWidget(self.formatPanel, 0, 0, 1, 2, Qt.AlignRight)
     grid.addWidget(self.genericTermRadioButton, 1, 0)
     grid.addWidget(self.genericTermLineEdit, 1, 1)
     eidLayout.addLayout(grid)
     eidLayout.addStretch()
     self.eidGroup.setLayout(eidLayout)
     layout.addWidget(self.eidGroup)
     layout.addWidget(self.buttonBox)
     self.setLayout(layout)
    def createElements(self):
        """
		Creates the widgets and docks of which the
		main window is composed.
		"""
        self.mainWindow = QMainWindow()
        projectController = ProjectController.Instance()
        self.transformTool = None

        # Render widgets
        self.fixedDataWidget = RenderWidget()
        self.movingDataWidget = RenderWidget()
        self.multiDataWidget = MultiRenderWidget()

        self.fixedRenderController = RenderController(self.fixedDataWidget,
                                                      "fixed")
        self.movingRenderController = RenderController(self.movingDataWidget,
                                                       "moving")
        self.multiRenderController = MultiRenderController(
            self.multiDataWidget)

        # Give references of the render controllers to the project controller
        projectController.fixedRenderController = self.fixedRenderController
        projectController.movingRenderController = self.movingRenderController
        projectController.multiRenderController = self.multiRenderController

        # Render properties widgets
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(1)

        self.fixedPropWidget = RenderPropWidget(self.fixedRenderController,
                                                parent=self)
        self.fixedPropWidget.setSizePolicy(sizePolicy)
        self.fixedPropWidget.setFileChangedSignal(
            projectController.fixedFileChanged)
        self.fixedPropWidget.setLoadDataSlot(self.loadFixedDataSetFile)

        self.movingPropWidget = RenderPropWidget(self.movingRenderController,
                                                 parent=self)
        self.movingPropWidget.setSizePolicy(sizePolicy)
        self.movingPropWidget.setFileChangedSignal(
            projectController.movingFileChanged)
        self.movingPropWidget.setLoadDataSlot(self.loadMovingDataSetFile)

        self.multiPropWidget = MultiRenderPropWidget(
            self.multiRenderController, parent=self)
        self.multiPropWidget.setSizePolicy(sizePolicy)

        self.verticalSplitter = QSplitter()
        self.verticalSplitter.setOrientation(Qt.Vertical)

        # Create the layouts

        fixedDataTitleWidget = TitleWidget("Fixed volume")
        multiDataTitleWidget = TitleWidget("Fixed + Moving")
        movingDataTitleWidget = TitleWidget("Moving volume")

        fixedLayout = QGridLayout()
        fixedLayout.setSpacing(0)
        fixedLayout.setContentsMargins(0, 0, 0, 0)
        fixedLayout.addWidget(fixedDataTitleWidget)
        fixedLayout.addWidget(self.fixedDataWidget)
        fixedWidget = QWidget()
        fixedWidget.setLayout(fixedLayout)

        multiLayout = QGridLayout()
        multiLayout.setSpacing(0)
        multiLayout.setContentsMargins(0, 0, 0, 0)
        multiLayout.addWidget(multiDataTitleWidget)
        multiLayout.addWidget(self.multiDataWidget)
        multiWidget = QWidget()
        multiWidget.setLayout(multiLayout)

        movingLayout = QGridLayout()
        movingLayout.setSpacing(0)
        movingLayout.setContentsMargins(0, 0, 0, 0)
        movingLayout.addWidget(movingDataTitleWidget)
        movingLayout.addWidget(self.movingDataWidget)
        movingWidget = QWidget()
        movingWidget.setLayout(movingLayout)

        horizontalSplitter = QSplitter()
        horizontalSplitter.setOrientation(Qt.Horizontal)
        horizontalSplitter.addWidget(fixedWidget)
        horizontalSplitter.addWidget(multiWidget)
        horizontalSplitter.addWidget(movingWidget)

        propsLayout = QHBoxLayout()
        propsLayout.setSpacing(1)
        propsLayout.setContentsMargins(0, 0, 0, 0)
        propsLayout.addWidget(self.fixedPropWidget)
        propsLayout.addWidget(self.multiPropWidget)
        propsLayout.addWidget(self.movingPropWidget)

        propsWidget = QWidget()
        propsWidget.setMinimumHeight(245)
        propsWidget.setMaximumHeight(350)
        propsWidget.setLayout(propsLayout)

        self.verticalSplitter.addWidget(horizontalSplitter)
        self.verticalSplitter.addWidget(propsWidget)
        self.verticalSplitter.setStretchFactor(0, 2)
        self.verticalSplitter.setStretchFactor(1, 1)
        self.setCentralWidget(self.verticalSplitter)
示例#37
0
class qHotField(QWidget):
    def __init__(self, name, mytype, initial_value, value_list = None, pos = "left", help_text = None, help_instance = None, min_size = 0, max_size = None, handler = None, multiline=False):
        QWidget.__init__(self)
        if max_size == None:
            max_size = 300
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) # Let it expand horizontally but not vertically
        self.name = name
        self.mytype = mytype
        self.multiline = multiline
        self.setContentsMargins(1, 1, 1, 1)
        self.is_popup = (value_list != None)
        if self.is_popup:
            self.value_list = [str(v) for v in value_list] # It's possible the values won't be strings.
        if pos == "top":
            self.layout1 = QVBoxLayout()
        else:
            self.layout1=QHBoxLayout()
        self.layout1.setContentsMargins(1, 1, 1, 1)
        self.layout1.setSpacing(1)
        self.setLayout(self.layout1)
        if mytype == bool:
            self.cb = QCheckBox(name)
            self.cb.setFont(regular_small_font)
            self.layout1.addWidget(self.cb)
            self.cb.setChecked(initial_value)
            if handler != None:
                self.cb.toggled.connect(handler)
        else:
            if not self.is_popup:
                if multiline:
                    self.efield=QPlainTextEdit("")
                    self.efield.appendPlainText(str(initial_value))
                else:
                    self.efield = QLineEdit("Default Text")
                    self.efield.setText(str(initial_value))
                if handler != None:
                    self.efield.textChanged.connect(handler)
            else:
                self.efield = QComboBox()
                self.efield.addItems(value_list)
                if len(value_list) != 0:
                    self.efield.setCurrentIndex(value_list.index(initial_value))
                self.efield.setSizeAdjustPolicy(QComboBox.AdjustToContents)
                if handler != None:
                    self.efield.currentIndexChanged.connect(handler)
                self.layout1.setContentsMargins(5, 5, 5, 5) # Popups need a little more space
                self.layout1.setSpacing(2)
            self.efield.setFont(regular_small_font)
            self.label = QLabel(name)
            self.label.setFont(regular_small_font)
            if pos == "right":
                self.layout1.addWidget(self.efield)
                self.layout1.addWidget(self.label)
            else:
                self.layout1.addWidget(self.label)
                self.layout1.addWidget(self.efield)
            
            self.efield.setMaximumWidth(max_size)
            if min_size != 0:
                self.efield.setMinimumWidth(min_size)
        self.layout1.addStretch()
        if help_text != None:
            if (help_instance == None):
                print "No help instance specified."
            else:
                help_button_widget = help_instance.create_button(name, help_text)
                self.layout1.addWidget(help_button_widget)
                    
    def repopulate_list(self, initial_value, value_list):
        if not self.is_popup:
            print "This qHotField is not a popup list. So it can't be repopulated"
            return
        self.value_list = [str(v) for v in value_list] # It's possible the values won't be strings
        self.efield.clear()
        self.efield.addItems(value_list)
        self.efield.setCurrentIndex(value_list.index(initial_value))
        return
        
    def get_myvalue(self):
        if self.mytype == bool:
            return self.cb.isChecked()
        else:
            if self.is_popup:
                the_txt = self.efield.currentText()
            else:
                if self.multiline:
                    the_txt = self.efield.toPlainText()
                else:
                    the_txt = self.efield.text()
            if (self.mytype == str) or (self.mytype == unicode):
                return (self.mytype)(the_txt)
            else: # if we have a numerical type, the user might have entered a list separated by spaces. Handle that specially
                the_val = re.findall(r"\S+", the_txt) # We might have a list of values separated by spaces if this is a numerical variable
                if len(the_val) == 1:  # it's just a single value
                    result = (self.mytype)(the_txt)
                else: # it's a list. We want to convert treat this as a monte sequence
                    res = []
                    for v in the_val:
                        res.append((self.mytype)(v))
                    result = MonteSequence(res)
                return result
        
    def set_myvalue(self, val):
        if self.mytype == bool:
            self.cb.setChecked(val)
        elif self.is_popup:
            self.efield.setCurrentIndex(self.value_list.index(val))
        else:
            if type(val) == list:
                result = ""
                for x in val:
                    result = result + str(x) + " "
                self.efield.setText(result)
            else:
                if self.multiline:
                    self.efield.clear()
                    self.efield.appendPlainText(str(val))
                else:
                    self.efield.setText(str(val))
    value = property(get_myvalue, set_myvalue)
class StatusCollapsibleLayout(QWidget):
    """ Collapsible layout with Maya Status Line's style """

    toggled = Signal(int)

    def __init__(self, parent=None, section_name=None):
        super(StatusCollapsibleLayout, self).__init__(parent)

        self.icon_buttons = []
        self.state = True

        self.toggle_btn = SeparatorButton()
        if section_name is None:
            section_name = 'Show/Hide section'
        self.toggle_btn.setToolTip(section_name)
        self.toggle_btn.setFlat(True)
        self.toggle_btn.clicked.connect(self.toggle_layout)

        self.group_layout = QHBoxLayout()
        self.group_layout.setAlignment(Qt.AlignLeft)
        self.group_layout.setContentsMargins(0, 0, 0, 0)
        self.group_layout.setSpacing(1)
        self.group_layout.addWidget(self.toggle_btn)

        self.setLayout(self.group_layout)

    def _delta_length(self):
        if self.state:
            return self.max_length() - TOOLBAR_SEPARATOR_WIDTH
        else:
            return TOOLBAR_SEPARATOR_WIDTH - self.max_length()

    def add_button(self, button):
        """ Create a button and add it to the layout

        :param button: QPushButton
        """
        self.icon_buttons.append(button)
        self.group_layout.addWidget(button)

    def toggle_layout(self, init=False):
        """ Toggle collapse action for layout """
        if not init:
            self.state = not self.state

        for btn in self.icon_buttons:
            btn.setVisible(self.state)

        self.toggle_btn.set_collapse(self.state)
        if init:
            self.toggled.emit(0 if self.state else self._delta_length())
        else:
            self.toggled.emit(self._delta_length())

    def set_current_state(self, state):
        self.state = state == 'true' if isinstance(state, unicode) else state
        self.toggle_layout(init=True)

    def button_count(self):
        return len(self.icon_buttons)

    def button_list(self):
        return self.icon_buttons

    def current_state(self):
        return self.state

    def max_length(self):
        count = self.button_count()
        # separator button width + button count * button size + spacing
        return TOOLBAR_SEPARATOR_WIDTH + count * TOOLBAR_BUTTON_SIZE + count
示例#39
0
    def __init__(self, *args, **kwargs):

        self.get_csv_form_google_spreadsheets(Widget_FileTree.url,
                                              Widget_FileTree.csv)
        self.dict_extensionList = self.get_dictList_from_csvPath(
            Widget_FileTree.csv)

        super(Widget_FileTree, self).__init__(*args, **kwargs)
        self.installEventFilter(self)

        mainLayout = QVBoxLayout(self)
        mainLayout.setContentsMargins(0, 5, 0, 0)

        w_basePath = QWidget()
        lay_basePath = QHBoxLayout(w_basePath)
        w_basePath.setStyleSheet("font-size:12px")
        lay_basePath.setContentsMargins(5, 0, 3, 0)
        label_basePath = QLabel("Base Path : ")
        lineEdit_basePath = QLineEdit()
        lineEdit_basePath.setMinimumHeight(22)
        lineEdit_basePath.setReadOnly(True)
        lay_basePath.addWidget(label_basePath)
        lay_basePath.addWidget(lineEdit_basePath)
        w_tree = QTreeWidget()
        w_tree.setColumnCount(2)
        headerItem = w_tree.headerItem()
        headerItem.setText(0, "File Path")
        headerItem.setText(1, "Target Node")
        w_tree.itemExpanded.connect(self.setContentsWidth)
        w_tree.itemCollapsed.connect(self.setContentsWidth)
        w_tree.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.w_typeAttrList = Widget_TypeAttributeList()

        w_tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        QtCore.QObject.connect(
            w_tree, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
            self.loadContextMenu)

        w_check = QWidget()
        lay_check = QHBoxLayout(w_check)
        lay_check.setContentsMargins(5, 5, 0, 10)
        lay_check.setSpacing(0)
        checkBox = QCheckBox()
        checkBox.setFixedWidth(30)
        label = QLabel("Show Unused files in folder")
        label.setStyleSheet("font-size:12px")
        lay_check.addWidget(checkBox)
        lay_check.addWidget(label)

        mainLayout.addWidget(w_basePath)
        mainLayout.addWidget(w_tree)
        mainLayout.addWidget(w_check)

        self.w_tree = w_tree
        self.checkBox = checkBox
        self.lineEdit = lineEdit_basePath

        self.load_checkBoxValue(checkBox, Widget_FileTree.path_uiInfo)

        QtCore.QObject.connect(checkBox, QtCore.SIGNAL("stateChanged(int)"),
                               self.saveCheckBoxValue)
        QtCore.QObject.connect(w_tree, QtCore.SIGNAL("itemSelectionChanged()"),
                               self.selectItem)
示例#40
0
文件: qt_gui.py 项目: gonicus/clacks
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # Global form layout
        form = QFormLayout()
        form.setContentsMargins(0, 0, 0, 0)

        # Header box containing label and icon
        hbox = QHBoxLayout()
        hbox.setSpacing(0)
        hbox.setContentsMargins(0, 0, 0, 0)

        header = QFrame()
        header.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        header.setStyleSheet("QWidget { background-color: white; color: black;}")

        header_text = QLabel("<b>" + _("Clacks Infrastructure") + "</b><br>" + "v%s" % VERSION)
        header_text.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 3;}")
        header_text.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        hbox.addWidget(header_text, 1)

        header_image = QLabel()
        header_image.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 0;}")
        header_image.setAlignment(Qt.AlignRight | Qt.AlignTop)

        bg = QPixmap(resource_filename("clacks.client", "data/secure-card.png"))
        header_image.setPixmap(bg)
        hbox.addWidget(header_image)
        header.setLayout(hbox)

        form.addRow(header)

        # Dialog headline
        headline = QLabel(_("Please enter the credentials of an administrative user to join this client."))
        headline.setWordWrap(True)
        headline.setStyleSheet("QLabel { padding: 3; }")
        form.addRow(headline)

        # Separator
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        form.addRow(line)

        # Input fields for user and password
        ll = QGridLayout()
        userLabel = QLabel("User name")
        self.userEdit = QLineEdit(self)
        passwordLabel = QLabel("Password")
        self.passwordEdit = QLineEdit(self)
        self.passwordEdit.setEchoMode(QLineEdit.Password)

        # Add focus key handler for line edits
        kpe = FocusNextOnReturn(self)
        self.userEdit.installEventFilter(kpe)
        aor = AcceptOnReturn(self)
        self.passwordEdit.installEventFilter(aor)

        # Place widgets in layout
        ll.addWidget(userLabel, 0, 0)
        ll.addWidget(self.userEdit, 0, 1)
        ll.addWidget(passwordLabel, 1, 0)
        ll.addWidget(self.passwordEdit, 1, 1)
        ll.setContentsMargins(3, 3, 3, 3)
        form.addRow(ll)

        # Separator
        line2 = QFrame()
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)
        form.addRow(line2)

        # OK button
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
        form.addRow(buttonBox)
        buttonBox.accepted.connect(self.accept)

        # Finalize the window
        self.setLayout(form)
        self.setMinimumSize(400, 150)
        self.setWindowTitle('Join client')

        self.setGeometry((QApplication.desktop().width() - self.sizeHint().width()) / 2,
            (QApplication.desktop().height() - self.sizeHint().height()) / 2,
            self.sizeHint().width(), self.sizeHint().height())

        # Disable close
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint | Qt.Window | Qt.WindowTitleHint)
class StatusScrollArea(QScrollArea):
    def __init__(self):
        super(StatusScrollArea, self).__init__()

        self._width = 0
        self._group_count = 0

        self._pan_pos = None

        self.__create_ui()
        self.__init_ui()

    def __create_ui(self):
        self.container = QWidget()
        self.container_layout = QHBoxLayout()

        self.container.setLayout(self.container_layout)
        self.setWidget(self.container)

    def __init_ui(self):
        self.container.setFixedHeight(TOOLBAR_BUTTON_SIZE)
        self.container_layout.setContentsMargins(0, 0, 0, 0)
        self.container_layout.setSpacing(1)
        self.container_layout.setAlignment(Qt.AlignLeft)

        self.setFixedHeight(TOOLBAR_BUTTON_SIZE)
        self.setFocusPolicy(Qt.NoFocus)
        self.setFrameShape(self.NoFrame)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

    def _update_width(self, expand_value):
        self._width += expand_value
        self.container.setFixedWidth(self._width + self._group_count)

    def mousePressEvent(self, event):
        if event.button() == Qt.MidButton:
            QApplication.setOverrideCursor(QCursor(Qt.SizeHorCursor))
            self._pan_pos = event.globalPos()
            event.accept()
        else:
            event.ignore()

    def mouseReleaseEvent(self, event):
        if event.button() == Qt.MidButton:
            QApplication.restoreOverrideCursor()
            self._pan_pos = None
            event.accept()
        else:
            event.ignore()

    def mouseMoveEvent(self, event):
        if self._pan_pos:
            h_bar = self.horizontalScrollBar()
            h_bar_pos = h_bar.sliderPosition()
            cursor_pos = event.globalPos()
            cursor_delta = (cursor_pos - self._pan_pos).x()

            h_bar.setValue(h_bar_pos - cursor_delta)
            self._pan_pos = cursor_pos
            event.accept()
        else:
            event.ignore()

    def wheelEvent(self, event):
        if event.orientation() == Qt.Vertical:
            num_degrees = event.delta() / 8
            h_bar = self.horizontalScrollBar()
            h_bar_pos = h_bar.sliderPosition()

            h_bar.setValue(h_bar_pos - num_degrees)
        else:
            super(StatusScrollArea, self).wheelEvent(event)

    def resizeEvent(self, event):
        max_scroll = max(0, self.container.width() - event.size().width())
        self.horizontalScrollBar().setMaximum(max_scroll)

    def add_widget(self, widget):
        # add widget to layout
        self.container_layout.addWidget(widget)

        # connect widget for future update when user interact with it
        widget.toggled.connect(self._update_width)

        # expand widget layout
        self._width += widget.max_length()
        self._group_count += 1
        self.container.setFixedWidth(self._width)
    def __init__(self, *args, **kwrgs):

        existing_widgets = Window.mayaWin.findChildren( QDialog, Window.objectName )
        if existing_widgets: map( lambda x: x.deleteLater(), existing_widgets )

        super( Window, self ).__init__( *args, **kwrgs )
        self.installEventFilter( self )
        self.setObjectName( Window.objectName )
        self.setWindowTitle( Window.title )

        mainLayout = QVBoxLayout( self ); mainLayout.setContentsMargins( 0,0,0,0 ); mainLayout.setSpacing(0)

        w_controller = Widget_loadObject( title="Controller", saveInfo=False )
        w_separator1 = Widget_Separator()
        w_target     = Widget_target()
        w_attrName = Widget_attributeName()
        w_startIndex = Widget_startIndex()
        w_buttons = QWidget()
        lay_buttons = QHBoxLayout( w_buttons ); lay_buttons.setContentsMargins( 10,0,10,10 ); lay_buttons.setSpacing( 0 )
        button_connect = QPushButton( "Connect" ); button_connect.setFixedHeight( 25 )
        button_close   = QPushButton( "Close" ); button_close.setFixedHeight( 25 )
        lay_buttons.addWidget( button_connect )
        lay_buttons.addWidget( button_close )

        mainLayout.addWidget(w_controller)
        mainLayout.addWidget(w_separator1)
        mainLayout.addWidget( w_target )
        mainLayout.addWidget(w_attrName)
        mainLayout.addWidget(w_startIndex)
        mainLayout.addWidget( w_buttons )

        self.resize( Window.defaultWidth, Window.defaultHeight )
        self.load_shapeInfo( Window.path_uiInfo )

        button_connect.clicked.connect( self.cmd_connect )
        button_close.clicked.connect( self.deleteLater )

        self.w_controller = w_controller
        self.w_target = w_target
        self.w_attrName = w_attrName
        self.w_startIndex = w_startIndex
示例#43
0
#button.text()

widget.adjustSize()

#button.deleteLater()

#createdLayout.count()

#createdButtons = map(lambda index: createdLayout.itemAt(index).widget(), range(createdLayout.count()))

#createdButtons

#createLayout.spacing()

#createLayout.setSpacing(0)
createLayout.setSpacing(3)
createdLayout.setSpacing(1)
layout.setSpacing(3)

#createdLayout.takeAt(createdLayout.count()-1).widget().deleteLater()

#widget.show()

#toremove = createdLayout.itemAt(createdLayout.count()-1).widget()
#createdLayout.removeWidget(toremove)
#toremove.deleteLater()
#createdLayout.itemAt(0)

def deleteCreated(toremove, tlayout):
    def delete():
        parent = toremove.parent()
示例#44
0
    def __init__(self, parent=None):
        """Initialize the parent class of this instance."""
        super(window, self).__init__(parent)
        app.aboutToQuit.connect(self.myExitHandler)

        self.style_sheet = self.styleSheet('style')
        # app.setStyle(QStyleFactory.create('Macintosh'))
        #app.setStyleSheet(self.style_sheet)
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0,0,0,0)

        app.setOrganizationName("Eivind Arvesen")
        app.setOrganizationDomain("https://github.com/eivind88/raskolnikov")
        app.setApplicationName("Raskolnikov")
        app.setApplicationVersion("0.0.1")
        settings = QSettings()

        self.data_location = QDesktopServices.DataLocation
        self.temp_location = QDesktopServices.TempLocation
        self.cache_location = QDesktopServices.CacheLocation

        self.startpage = "https://duckduckgo.com/"
        self.new_tab_behavior = "insert"

        global bookmarks

        global saved_tabs
        print "Currently saved_tabs:\n", saved_tabs

        global menubar
        menubar = QMenuBar()

        # Initialize a statusbar for the window
        self.statusbar = self.statusBar()
        self.statusbar.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
        self.statusbar.setStyleSheet(self.style_sheet)
        self.statusbar.setMinimumHeight(15)

        self.pbar = QProgressBar()
        self.pbar.setMaximumWidth(100)
        self.statusbar.addPermanentWidget(self.pbar)

        self.statusbar.hide()

        self.setMinimumSize(504, 235)
        # self.setWindowModified(True)
        # app.alert(self, 0)
        self.setWindowTitle("Raskolnikov")
        # toolbar = self.addToolBar('Toolbar')
        # toolbar.addAction(exitAction)
        # self.setUnifiedTitleAndToolBarOnMac(True)
        self.setWindowIcon(QIcon(""))

        # Create input widgets
        self.bbutton = QPushButton(u"<")
        self.fbutton = QPushButton(u">")
        self.hbutton = QPushButton(u"⌂")
        self.edit = QLineEdit("")
        self.edit.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
        self.edit.setPlaceholderText("Enter URL")
        # self.edit.setMinimumSize(400, 24)
        self.rbutton = QPushButton(u"↻")
        self.dbutton = QPushButton(u"☆")
        self.tbutton = QPushButton(u"⁐")
        # ↆ ⇧ √ ⌘ ⏎ ⏏ ⚠ ✓ ✕ ✖ ✗ ✘ ::: ❤ ☮ ☢ ☠ ✔ ☑ ♥ ✉ ☣ ☤ ✘ ☒ ♡ ツ ☼ ☁ ❅ ✎
        self.nbutton = QPushButton(u"+")
        self.nbutton.setObjectName("NewTab")
        self.nbutton.setMinimumSize(35, 30)
        self.nbutton.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        self.edit.setTextMargins(2, 1, 2, 0)

        # create a horizontal layout for the input
        input_layout = QHBoxLayout()
        input_layout.setSpacing(4)
        input_layout.setContentsMargins(0, 0, 0, 0)

        # add the input widgets to the input layout
        input_layout.addWidget(self.bbutton)
        input_layout.addWidget(self.fbutton)
        input_layout.addWidget(self.hbutton)
        input_layout.addWidget(self.edit)
        input_layout.addWidget(self.rbutton)
        input_layout.addWidget(self.dbutton)
        input_layout.addWidget(self.tbutton)

        # create a widget to hold the input layout
        self.input_widget = QFrame()
        self.input_widget.setObjectName("InputWidget")
        self.input_widget.setStyleSheet(self.style_sheet)

        # set the layout of the widget
        self.input_widget.setLayout(input_layout)
        self.input_widget.setVisible(True)

        # CREATE BOOKMARK-LINE HERE
        self.bookmarks_layout = QHBoxLayout()
        self.bookmarks_layout.setSpacing(0)
        self.bookmarks_layout.setContentsMargins(0, 0, 0, 0)

        for i in bookmarks:
            link = QToolButton()
            link.setDefaultAction(QAction(unicode(i), link))
            link.setObjectName(unicode(i))
            link.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
            link.clicked.connect(self.handleBookmarks)

            self.bookmarks_layout.addWidget(link)

        self.bookmarks_widget = QFrame()
        self.bookmarks_widget.setObjectName("BookmarkWidget")
        self.bookmarks_widget.setStyleSheet(self.style_sheet)
        self.bookmarks_widget.setLayout(self.bookmarks_layout)

        if not bookmarks:
            self.bookmarks_widget.hide()

        # Task list
        self.tasklist = QStandardItemModel()
        #parentItem = self.tasklist.invisibleRootItem()
        #self.tasklist.header().hide()
        self.tasklist.setHorizontalHeaderItem(0, QStandardItem('Tasks'))
        parentItem = QStandardItem("Parent")
        self.tasklist.appendRow(parentItem)
        for i in range(4):
            item = QStandardItem("Item %d" % i)
            parentItem.appendRow(item)
            #parentItem = item

        #self.list.activated[str].connect(self.handleBookmarks)
        #self.list.view().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        # create tabs
        self.tabs = QTabWidget()
        self.tabs.setDocumentMode(True)
        self.tabs.setTabsClosable(True)
        self.tabs.setMovable(True)
        self.tabs.tabBar().hide()
        self.tabs.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
        self.tabs.setCornerWidget(self.nbutton)
        self.tabs.cornerWidget().setObjectName("CornerWidget")
        self.tabs.cornerWidget().setMinimumSize(10, 24)
        self.tabs.cornerWidget().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        if saved_tabs:
            for tab in saved_tabs['tabs']:
                tasklist = QTreeView()
                tasklist.hide()
                tasklist.setObjectName('taskList')
                tasklist.setMinimumWidth(100)
                tasklist.setMaximumWidth(250)

                new_tab = QWebView()
                new_tab.setObjectName('webView')

                inspector = QWebInspector(self)
                inspector.setObjectName('webInspector')
                inspector.hide()

                page_layout = QVBoxLayout()
                page_layout.setSpacing(0)
                page_layout.setContentsMargins(0, 0, 0, 0)
                page_layout.addWidget(new_tab)
                page_layout.addWidget(inspector)
                page_widget = QFrame()
                page_widget.setObjectName('pageWidget')
                page_widget.setLayout(page_layout)

                complete_tab_layout = QHBoxLayout()
                complete_tab_layout.setSpacing(0)
                complete_tab_layout.setContentsMargins(0, 0, 0, 0)
                complete_tab_layout.addWidget(tasklist)
                complete_tab_layout.addWidget(page_widget)
                complete_tab_widget = QFrame()
                complete_tab_widget.setLayout(complete_tab_layout)

                #for page in tab['history']:
                #    new_tab.load(QUrl(page['url']))
                #print tab['current_history']
                #for item in new_tab.history().items():
                #    print item
                #new_tab.history().goToItem(new_tab.history().itemAt(tab['current_history']))
                new_tab.load(QUrl(tab['history'][tab['current_history']]['url']))
                tab['current_history']
                self.tabs.setUpdatesEnabled(False)
                if self.new_tab_behavior == "insert":
                    self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                        unicode(new_tab.title()))
                elif self.new_tab_behavior == "append":
                    self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
                self.tabs.setUpdatesEnabled(True)
                new_tab.titleChanged.connect(self.change_tab)
                new_tab.urlChanged.connect(self.change_tab)
                new_tab.loadStarted.connect(self.load_start)
                new_tab.loadFinished.connect(self.load_finish)
                new_tab.loadProgress.connect(self.pbar.setValue)
                new_tab.page().linkHovered.connect(self.linkHover)
                inspector.setPage(new_tab.page())

            for index, tab in enumerate(saved_tabs['tabs']):
                self.tabs.setTabText(index, tab['history'][tab['current_history']]['title'])

            self.tabs.setCurrentIndex(saved_tabs['current_tab'])
        else:
            self.new_tab()

        tabs_layout = QVBoxLayout()
        tabs_layout.setSpacing(0)
        tabs_layout.setContentsMargins(0, 0, 0, 0)
        tabs_layout.addWidget(self.tabs)

        self.tabs_widget = QFrame()
        self.tabs_widget.setObjectName("TabLine")
        self.tabs_widget.setStyleSheet(self.style_sheet)
        self.tabs_widget.setLayout(tabs_layout)
        self.tabs_widget.setVisible(True)

        # Webkit settings
        gsettings = self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).settings().globalSettings()
        # Basic settings
        gsettings.setAttribute(QWebSettings.AutoLoadImages, True)
        gsettings.setAttribute(QWebSettings.JavascriptEnabled, True)
        gsettings.setAttribute(QWebSettings.JavascriptCanOpenWindows, False)
        gsettings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, False)
        gsettings.setAttribute(QWebSettings.PluginsEnabled, False) # Flash isn't stable at present
        gsettings.setAttribute(QWebSettings.JavaEnabled, False) # Java applet's aren't supported by PySide
        gsettings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled,
            True)
        # Performace settings
        gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
        gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        # Other settings
        gsettings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False)

        # Create a vertical layout and add widgets
        vlayout = QVBoxLayout()
        vlayout.setSpacing(0)
        vlayout.setContentsMargins(0, 0, 0, 0)
        # toolbar.addWidget(self.input_widget)
        vlayout.addWidget(self.input_widget)
        vlayout.addWidget(self.bookmarks_widget)
        vlayout.addWidget(self.tabs_widget)

        # create a widget to hold the vertical layout
        wrapper_widget = QWidget()
        wrapper_widget.setLayout(vlayout)
        self.setCentralWidget(wrapper_widget)

        self.bbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).back)
        self.fbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).forward)
        self.hbutton.clicked.connect(self.goHome)
        self.edit.returnPressed.connect(self.set_url)
        # Add button signal to "go" slot
        self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)
        self.dbutton.clicked.connect(self.bookmark)
        self.tbutton.clicked.connect(self.toggleTaskBar)
        self.nbutton.clicked.connect(self.new_tab)
        self.tabs.tabCloseRequested.connect(self.tabs.removeTab)
        self.tabs.currentChanged.connect(self.change_tab)

        widgets = (input_layout.itemAt(i).widget() for i in range(
            input_layout.count()))
        for widget in widgets:
            if isinstance(widget, QPushButton):
                widget.setFixedSize(33, 21)
                widget.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
                widget.pressed.connect(self.press_button)
                widget.released.connect(self.release_button)

        # make a ctrl+q quit
        sequence = QKeySequence(Qt.CTRL + Qt.Key_Q)
        QShortcut(sequence, self, SLOT("close()"))

        # make an accelerator to toggle fullscreen
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_F)
        QShortcut(sequence, self, self.toggle_fullscreen)

        # make an accelerator to toggle input visibility
        sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_L)
        QShortcut(sequence, self, self.toggle_input)

        # make an accelerator to focus adress-bar
        sequence = QKeySequence(Qt.CTRL + Qt.Key_L)
        QShortcut(sequence, self, self.focus_adress)

        # make an accelerator to reload page
        sequence = QKeySequence(Qt.CTRL + Qt.Key_R)
        QShortcut(sequence, self, self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)

        # make an accelerator to create new tab
        sequence = QKeySequence(Qt.CTRL + Qt.Key_T)
        QShortcut(sequence, self, self.new_tab)

        # make an accelerator to close tab
        sequence = QKeySequence(Qt.CTRL + Qt.Key_W)
        QShortcut(sequence, self, self.close_tab)

        # make an accelerator to navigate tabs
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Left)
        QShortcut(sequence, self, self.previous_tab)
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Right)
        QShortcut(sequence, self, self.next_tab)

        # make an accelerator to toggle inspector
        sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_U)
        QShortcut(sequence, self, self.handleShowInspector)

        # make an accelerator to toggle bookmark
        sequence = QKeySequence(Qt.CTRL + Qt.Key_D)
        QShortcut(sequence, self, self.bookmark)

        # make an accelerator to toggle task/project-list
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_L)
        QShortcut(sequence, self, self.toggleTaskBar)

        # finally set the attribute need to rotate
        # try:
        #     self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
        # except:
        #     print "not maemo"

        self.statusbar.show()
示例#45
0
 def layoutWidgets(self):
     layout = QVBoxLayout()
     entryLayout = QHBoxLayout()
     entryLayout.setSpacing(0)
     entryLayout.addWidget(self.entryLabel)
     entryLayout.addWidget(self.termLabel)
     entryLayout.addStretch()
     layout.addLayout(entryLayout)
     eidLayout = QVBoxLayout()
     eidLayout.addWidget(self.copyToTopRadioButton)
     eidLayout.addWidget(self.subentryRadioButton)
     eidLayout.addWidget(self.siblingRadioButton)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.filteredRadioButton)
     hbox.addWidget(self.filteredLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.circledRadioButton)
     hbox.addWidget(self.circledLabel, 1)
     eidLayout.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.recentRadioButton)
     hbox.addWidget(self.recentComboBox, 1)
     eidLayout.addLayout(hbox)
     eidLayout.addStretch()
     self.eidGroup.setLayout(eidLayout)
     layout.addWidget(self.eidGroup)
     vbox = QVBoxLayout()
     hbox = QHBoxLayout()
     hbox.addWidget(self.copyAllCheckBox)
     hbox.addWidget(self.copyXrefsCheckBox)
     hbox.addWidget(self.copyGroupsCheckBox)
     hbox.addWidget(self.copySubentriesCheckBox)
     hbox.addStretch()
     vbox.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.linkPagesCheckBox)
     hbox.addWidget(self.linkLabel)
     hbox.addStretch()
     vbox.addLayout(hbox)
     hbox = QHBoxLayout()
     hbox.setSpacing(0)
     hbox.addWidget(self.withSeeCheckBox)
     hbox.addWidget(self.withSeeLabel1)
     hbox.addStretch()
     vbox.addLayout(hbox)
     vbox.addWidget(self.withSeeLabel2)
     self.optionsGroup.setLayout(vbox)
     layout.addWidget(self.optionsGroup)
     layout.addWidget(self.buttonBox)
     self.setLayout(layout)
示例#46
0
class window(QMainWindow):

    """Main window."""

    def __init__(self, parent=None):
        """Initialize the parent class of this instance."""
        super(window, self).__init__(parent)
        app.aboutToQuit.connect(self.myExitHandler)

        self.style_sheet = self.styleSheet('style')
        # app.setStyle(QStyleFactory.create('Macintosh'))
        #app.setStyleSheet(self.style_sheet)
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0,0,0,0)

        app.setOrganizationName("Eivind Arvesen")
        app.setOrganizationDomain("https://github.com/eivind88/raskolnikov")
        app.setApplicationName("Raskolnikov")
        app.setApplicationVersion("0.0.1")
        settings = QSettings()

        self.data_location = QDesktopServices.DataLocation
        self.temp_location = QDesktopServices.TempLocation
        self.cache_location = QDesktopServices.CacheLocation

        self.startpage = "https://duckduckgo.com/"
        self.new_tab_behavior = "insert"

        global bookmarks

        global saved_tabs
        print "Currently saved_tabs:\n", saved_tabs

        global menubar
        menubar = QMenuBar()

        # Initialize a statusbar for the window
        self.statusbar = self.statusBar()
        self.statusbar.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
        self.statusbar.setStyleSheet(self.style_sheet)
        self.statusbar.setMinimumHeight(15)

        self.pbar = QProgressBar()
        self.pbar.setMaximumWidth(100)
        self.statusbar.addPermanentWidget(self.pbar)

        self.statusbar.hide()

        self.setMinimumSize(504, 235)
        # self.setWindowModified(True)
        # app.alert(self, 0)
        self.setWindowTitle("Raskolnikov")
        # toolbar = self.addToolBar('Toolbar')
        # toolbar.addAction(exitAction)
        # self.setUnifiedTitleAndToolBarOnMac(True)
        self.setWindowIcon(QIcon(""))

        # Create input widgets
        self.bbutton = QPushButton(u"<")
        self.fbutton = QPushButton(u">")
        self.hbutton = QPushButton(u"⌂")
        self.edit = QLineEdit("")
        self.edit.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
        self.edit.setPlaceholderText("Enter URL")
        # self.edit.setMinimumSize(400, 24)
        self.rbutton = QPushButton(u"↻")
        self.dbutton = QPushButton(u"☆")
        self.tbutton = QPushButton(u"⁐")
        # ↆ ⇧ √ ⌘ ⏎ ⏏ ⚠ ✓ ✕ ✖ ✗ ✘ ::: ❤ ☮ ☢ ☠ ✔ ☑ ♥ ✉ ☣ ☤ ✘ ☒ ♡ ツ ☼ ☁ ❅ ✎
        self.nbutton = QPushButton(u"+")
        self.nbutton.setObjectName("NewTab")
        self.nbutton.setMinimumSize(35, 30)
        self.nbutton.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        self.edit.setTextMargins(2, 1, 2, 0)

        # create a horizontal layout for the input
        input_layout = QHBoxLayout()
        input_layout.setSpacing(4)
        input_layout.setContentsMargins(0, 0, 0, 0)

        # add the input widgets to the input layout
        input_layout.addWidget(self.bbutton)
        input_layout.addWidget(self.fbutton)
        input_layout.addWidget(self.hbutton)
        input_layout.addWidget(self.edit)
        input_layout.addWidget(self.rbutton)
        input_layout.addWidget(self.dbutton)
        input_layout.addWidget(self.tbutton)

        # create a widget to hold the input layout
        self.input_widget = QFrame()
        self.input_widget.setObjectName("InputWidget")
        self.input_widget.setStyleSheet(self.style_sheet)

        # set the layout of the widget
        self.input_widget.setLayout(input_layout)
        self.input_widget.setVisible(True)

        # CREATE BOOKMARK-LINE HERE
        self.bookmarks_layout = QHBoxLayout()
        self.bookmarks_layout.setSpacing(0)
        self.bookmarks_layout.setContentsMargins(0, 0, 0, 0)

        for i in bookmarks:
            link = QToolButton()
            link.setDefaultAction(QAction(unicode(i), link))
            link.setObjectName(unicode(i))
            link.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
            link.clicked.connect(self.handleBookmarks)

            self.bookmarks_layout.addWidget(link)

        self.bookmarks_widget = QFrame()
        self.bookmarks_widget.setObjectName("BookmarkWidget")
        self.bookmarks_widget.setStyleSheet(self.style_sheet)
        self.bookmarks_widget.setLayout(self.bookmarks_layout)

        if not bookmarks:
            self.bookmarks_widget.hide()

        # Task list
        self.tasklist = QStandardItemModel()
        #parentItem = self.tasklist.invisibleRootItem()
        #self.tasklist.header().hide()
        self.tasklist.setHorizontalHeaderItem(0, QStandardItem('Tasks'))
        parentItem = QStandardItem("Parent")
        self.tasklist.appendRow(parentItem)
        for i in range(4):
            item = QStandardItem("Item %d" % i)
            parentItem.appendRow(item)
            #parentItem = item

        #self.list.activated[str].connect(self.handleBookmarks)
        #self.list.view().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        # create tabs
        self.tabs = QTabWidget()
        self.tabs.setDocumentMode(True)
        self.tabs.setTabsClosable(True)
        self.tabs.setMovable(True)
        self.tabs.tabBar().hide()
        self.tabs.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
        self.tabs.setCornerWidget(self.nbutton)
        self.tabs.cornerWidget().setObjectName("CornerWidget")
        self.tabs.cornerWidget().setMinimumSize(10, 24)
        self.tabs.cornerWidget().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)

        if saved_tabs:
            for tab in saved_tabs['tabs']:
                tasklist = QTreeView()
                tasklist.hide()
                tasklist.setObjectName('taskList')
                tasklist.setMinimumWidth(100)
                tasklist.setMaximumWidth(250)

                new_tab = QWebView()
                new_tab.setObjectName('webView')

                inspector = QWebInspector(self)
                inspector.setObjectName('webInspector')
                inspector.hide()

                page_layout = QVBoxLayout()
                page_layout.setSpacing(0)
                page_layout.setContentsMargins(0, 0, 0, 0)
                page_layout.addWidget(new_tab)
                page_layout.addWidget(inspector)
                page_widget = QFrame()
                page_widget.setObjectName('pageWidget')
                page_widget.setLayout(page_layout)

                complete_tab_layout = QHBoxLayout()
                complete_tab_layout.setSpacing(0)
                complete_tab_layout.setContentsMargins(0, 0, 0, 0)
                complete_tab_layout.addWidget(tasklist)
                complete_tab_layout.addWidget(page_widget)
                complete_tab_widget = QFrame()
                complete_tab_widget.setLayout(complete_tab_layout)

                #for page in tab['history']:
                #    new_tab.load(QUrl(page['url']))
                #print tab['current_history']
                #for item in new_tab.history().items():
                #    print item
                #new_tab.history().goToItem(new_tab.history().itemAt(tab['current_history']))
                new_tab.load(QUrl(tab['history'][tab['current_history']]['url']))
                tab['current_history']
                self.tabs.setUpdatesEnabled(False)
                if self.new_tab_behavior == "insert":
                    self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                        unicode(new_tab.title()))
                elif self.new_tab_behavior == "append":
                    self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
                self.tabs.setUpdatesEnabled(True)
                new_tab.titleChanged.connect(self.change_tab)
                new_tab.urlChanged.connect(self.change_tab)
                new_tab.loadStarted.connect(self.load_start)
                new_tab.loadFinished.connect(self.load_finish)
                new_tab.loadProgress.connect(self.pbar.setValue)
                new_tab.page().linkHovered.connect(self.linkHover)
                inspector.setPage(new_tab.page())

            for index, tab in enumerate(saved_tabs['tabs']):
                self.tabs.setTabText(index, tab['history'][tab['current_history']]['title'])

            self.tabs.setCurrentIndex(saved_tabs['current_tab'])
        else:
            self.new_tab()

        tabs_layout = QVBoxLayout()
        tabs_layout.setSpacing(0)
        tabs_layout.setContentsMargins(0, 0, 0, 0)
        tabs_layout.addWidget(self.tabs)

        self.tabs_widget = QFrame()
        self.tabs_widget.setObjectName("TabLine")
        self.tabs_widget.setStyleSheet(self.style_sheet)
        self.tabs_widget.setLayout(tabs_layout)
        self.tabs_widget.setVisible(True)

        # Webkit settings
        gsettings = self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).settings().globalSettings()
        # Basic settings
        gsettings.setAttribute(QWebSettings.AutoLoadImages, True)
        gsettings.setAttribute(QWebSettings.JavascriptEnabled, True)
        gsettings.setAttribute(QWebSettings.JavascriptCanOpenWindows, False)
        gsettings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, False)
        gsettings.setAttribute(QWebSettings.PluginsEnabled, False) # Flash isn't stable at present
        gsettings.setAttribute(QWebSettings.JavaEnabled, False) # Java applet's aren't supported by PySide
        gsettings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled,
            True)
        # Performace settings
        gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
        gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        # Other settings
        gsettings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False)

        # Create a vertical layout and add widgets
        vlayout = QVBoxLayout()
        vlayout.setSpacing(0)
        vlayout.setContentsMargins(0, 0, 0, 0)
        # toolbar.addWidget(self.input_widget)
        vlayout.addWidget(self.input_widget)
        vlayout.addWidget(self.bookmarks_widget)
        vlayout.addWidget(self.tabs_widget)

        # create a widget to hold the vertical layout
        wrapper_widget = QWidget()
        wrapper_widget.setLayout(vlayout)
        self.setCentralWidget(wrapper_widget)

        self.bbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).back)
        self.fbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).forward)
        self.hbutton.clicked.connect(self.goHome)
        self.edit.returnPressed.connect(self.set_url)
        # Add button signal to "go" slot
        self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)
        self.dbutton.clicked.connect(self.bookmark)
        self.tbutton.clicked.connect(self.toggleTaskBar)
        self.nbutton.clicked.connect(self.new_tab)
        self.tabs.tabCloseRequested.connect(self.tabs.removeTab)
        self.tabs.currentChanged.connect(self.change_tab)

        widgets = (input_layout.itemAt(i).widget() for i in range(
            input_layout.count()))
        for widget in widgets:
            if isinstance(widget, QPushButton):
                widget.setFixedSize(33, 21)
                widget.setFont(QFont("Helvetica Neue", 12, QFont.Normal))
                widget.pressed.connect(self.press_button)
                widget.released.connect(self.release_button)

        # make a ctrl+q quit
        sequence = QKeySequence(Qt.CTRL + Qt.Key_Q)
        QShortcut(sequence, self, SLOT("close()"))

        # make an accelerator to toggle fullscreen
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_F)
        QShortcut(sequence, self, self.toggle_fullscreen)

        # make an accelerator to toggle input visibility
        sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_L)
        QShortcut(sequence, self, self.toggle_input)

        # make an accelerator to focus adress-bar
        sequence = QKeySequence(Qt.CTRL + Qt.Key_L)
        QShortcut(sequence, self, self.focus_adress)

        # make an accelerator to reload page
        sequence = QKeySequence(Qt.CTRL + Qt.Key_R)
        QShortcut(sequence, self, self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)

        # make an accelerator to create new tab
        sequence = QKeySequence(Qt.CTRL + Qt.Key_T)
        QShortcut(sequence, self, self.new_tab)

        # make an accelerator to close tab
        sequence = QKeySequence(Qt.CTRL + Qt.Key_W)
        QShortcut(sequence, self, self.close_tab)

        # make an accelerator to navigate tabs
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Left)
        QShortcut(sequence, self, self.previous_tab)
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Right)
        QShortcut(sequence, self, self.next_tab)

        # make an accelerator to toggle inspector
        sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_U)
        QShortcut(sequence, self, self.handleShowInspector)

        # make an accelerator to toggle bookmark
        sequence = QKeySequence(Qt.CTRL + Qt.Key_D)
        QShortcut(sequence, self, self.bookmark)

        # make an accelerator to toggle task/project-list
        sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_L)
        QShortcut(sequence, self, self.toggleTaskBar)

        # finally set the attribute need to rotate
        # try:
        #     self.setAttribute(Qt.WA_Maemo5AutoOrientation, True)
        # except:
        #     print "not maemo"

        self.statusbar.show()

    def press_button(self):
        """On button press. Connected."""
        self.sender().setStyleSheet('background-color: rgba(228, 228, 228)')

    def release_button(self):
        """On button release. Connected."""
        self.sender().setStyleSheet('background-color: rgba(252, 252, 252)')

    def goHome(self):
        """Go to startpage."""
        self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).setUrl(QUrl(self.startpage))

    def handleShowInspector(self):
        """Toggle web inspector."""
        self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebInspector, unicode('webInspector')).setShown(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebInspector, unicode('webInspector')).isHidden())

    def toggleTaskBar(self):
        """Toggle task bar."""
        if self.tabs.currentWidget().findChild(QTreeView, unicode('taskList')).isHidden():
            self.tabs.currentWidget().findChild(QTreeView, unicode('taskList')).setModel(self.tasklist)
        self.tabs.currentWidget().findChild(QTreeView, unicode('taskList')).setShown(self.tabs.currentWidget().findChild(QTreeView, unicode('taskList')).isHidden())
        #self.tasklist.setShown(self.tasklist.isHidden())

    def focus_adress(self):
        """Focus adress bar."""
        self.edit.selectAll()
        self.edit.setFocus()

    def toggle_input(self):
        """Toggle input visibility."""
        if self.input_widget.isVisible():
            visible = False
        else:
            visible = True
        self.input_widget.setVisible(visible)

    def toggle_fullscreen(self):
        """Toggle fullscreen."""
        if self.isFullScreen():
            self.showNormal()
        else:
            self.showFullScreen()
        self.change_tab()

    def linkHover(self, l):
        """Show link adress in status bar on mouse hover."""
        self.statusbar.showMessage(l)

    def new_tab(self):
        """Open new tab."""
        tasklist = QTreeView()
        tasklist.hide()
        tasklist.setObjectName('taskList')
        tasklist.setMinimumWidth(100)
        tasklist.setMaximumWidth(250)

        new_tab = QWebView()
        new_tab.setObjectName('webView')

        inspector = QWebInspector(self)
        inspector.setObjectName('webInspector')
        inspector.hide()

        page_layout = QVBoxLayout()
        page_layout.setSpacing(0)
        page_layout.setContentsMargins(0, 0, 0, 0)
        page_layout.addWidget(new_tab)
        page_layout.addWidget(inspector)
        page_widget = QFrame()
        page_widget.setObjectName('pageWidget')
        page_widget.setLayout(page_layout)

        complete_tab_layout = QHBoxLayout()
        complete_tab_layout.setSpacing(0)
        complete_tab_layout.setContentsMargins(0, 0, 0, 0)
        complete_tab_layout.addWidget(tasklist)
        complete_tab_layout.addWidget(page_widget)
        complete_tab_widget = QFrame()
        complete_tab_widget.setLayout(complete_tab_layout)

        new_tab.load(QUrl(self.startpage))
        self.tabs.setUpdatesEnabled(False)
        if self.new_tab_behavior == "insert":
            self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                    unicode(new_tab.title()))
        elif self.new_tab_behavior == "append":
            self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
        self.tabs.setCurrentWidget(complete_tab_widget)
        self.tabs.setTabText(self.tabs.currentIndex(),
                             unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
        self.tabs.setUpdatesEnabled(True)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        new_tab.titleChanged.connect(self.change_tab)
        new_tab.urlChanged.connect(self.change_tab)
        new_tab.loadStarted.connect(self.load_start)
        new_tab.loadFinished.connect(self.load_finish)
        new_tab.loadProgress.connect(self.pbar.setValue)
        new_tab.page().linkHovered.connect(self.linkHover)
        inspector.setPage(new_tab.page())

    def change_tab(self):
        """Change active tab."""
        if self.tabs.count() <= 1:
            self.tabs.tabBar().hide()
        else:
            self.tabs.tabBar().show()

        try:
            self.edit.setText(str(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded()))
            self.tabs.setTabText(self.tabs.currentIndex(),
                                 unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
            self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).setFocus()
        except Exception:
            self.tabs.tabBar().hide()
            self.new_tab()

        #print (self.tabs.widget(self.tabs.currentIndex()).size().width()-10), self.tabs.count()
        self.tabs_widget.setStyleSheet(self.style_sheet +
                                       "QTabBar::tab { width:" + str(
                                        (self.tabs.widget(
                                            self.tabs.currentIndex()
                                            ).size().width()-26-self.tabs.count()*2)/self.tabs.count()
                                        ) + "px; }")

    def previous_tab(self):
        """Previous tab."""
        try:
            if self.tabs.currentIndex() > 0:
                self.tabs.setCurrentIndex(self.tabs.currentIndex()-1)
            else:
                self.tabs.setCurrentIndex(self.tabs.count()-1)

            self.change_tab()
        except Exception:
            pass

    def next_tab(self):
        """Next tab."""
        try:
            if self.tabs.currentIndex() < self.tabs.count()-1:
                self.tabs.setCurrentIndex(self.tabs.currentIndex()+1)
            else:
                self.tabs.setCurrentIndex(0)

            self.change_tab()
        except Exception: #, e
            pass

    def close_tab(self):
        """Close tab."""
        self.tabs.removeTab(self.tabs.currentIndex())

    def close(self):
        """Close app."""
        Qapplication.quit()

    def set_url(self):
        """Set url."""
        url = self.edit.text()
        # does the url start with http://?
        if "." not in url:
            url = "http://www.google.com/search?q="+url
        elif not url.startswith("http://"):
            url = "http://" + url
        qurl = QUrl(url)
        self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).load(qurl)
        self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).setFocus()

    def load_start(self):
        """Update view values, called upon started page load."""
        self.rbutton.setText(u"╳")
        self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).stop)
        self.pbar.show()

    def load_finish(self):
        """Update view values, called upon finished page load."""
        if (self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).history().canGoBack()):
            self.bbutton.setEnabled(True)
        else:
            self.bbutton.setEnabled(False)
        if (self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).history().canGoForward()):
            self.fbutton.setEnabled(True)
        else:
            self.fbutton.setEnabled(False)

        self.rbutton.setText(u"↻")
        self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload)
        self.pbar.hide()

        global bookmarks
        if unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded()) in bookmarks:
            self.dbutton.setText(u"★")
        else:
            self.dbutton.setText(u"☆")

        if not self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebInspector, unicode('webInspector')).isHidden():
            self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebInspector, unicode('webInspector')).hide()
            self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebInspector, unicode('webInspector')).show()

    def bookmark(self):
        """Toggle bookmark."""
        global bookmarks
        if not self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded() in bookmarks:
            bookmarks.append(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded())
            pickle.dump(bookmarks, open(bookFile, "wb"))
            link = QToolButton()
            link.setDefaultAction(QAction(unicode(unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded())), link))
            link.setObjectName(unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded()))
            link.setFont(QFont("Helvetica Neue", 11, QFont.Normal))
            link.clicked.connect(self.handleBookmarks)
            self.bookmarks_layout.addWidget(link)

            if self.bookmarks_widget.isHidden():
                self.bookmarks_widget.show()

            self.dbutton.setText(u"★")

        else:
            bookmarks.remove(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded())
            pickle.dump(bookmarks, open(bookFile, "wb"))
            link = self.bookmarks_widget.findChild(QToolButton, unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded()))
            self.bookmarks_layout.removeWidget(link)
            link.deleteLater()
            link = None

            if not bookmarks:
                self.bookmarks_widget.hide()

            self.dbutton.setText(u"☆")

    def handleBookmarks(self):

        self.gotoLink(self.sender().objectName())
        #self.gotoLink(unicode())

    def gotoLink(self, url):

        self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).load(QUrl(url))

    def styleSheet(self, style_sheet):
        """Load stylesheet."""
        try:
            with open(os.path.join
                      (basedir, 'assets', 'style.qss'), 'r') as file:
                return file.read()
        except Exception:
            # print e
            return ''

    def resizeEvent(self, evt=None):
        """Called on window resize."""
        self.change_tab()

    def myExitHandler(self):
        """Exiting."""
        pass
        global tabFile

    # {current_tab: 1, tabs:[0: {current_history:3, history:[{title, url}]]}
        pb = {'current_tab': self.tabs.currentIndex()}
        pb['tabs'] = list()
        for tab in range(self.tabs.count()):
            pb['tabs'].append(dict(current_history=self.tabs.widget(
                tab).findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).history().currentItemIndex(), history=list(dict(
                    title=item.title(), url=item.url()
                    ) for item in self.tabs.widget(tab).findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).history().items())))

        # print pb
        pickle.dump(pb, open(tabFile, "wb"))
示例#47
0
class ToolbarWidget(QWidget):
    """
	ToolbarWidget
	"""
    def __init__(self):
        super(ToolbarWidget, self).__init__()

        # Make sure the widget expands over the whole toolbar
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Create main layout that will contain the layouts for each section
        self.mainLayout = QHBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)

        # Layout on the left side
        self.leftLayout = QHBoxLayout()
        self.leftLayout.setContentsMargins(0, 0, 0, 0)
        self.leftLayout.setSpacing(0)
        self.leftLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        # Layout in the center
        self.centerLayout = QHBoxLayout()
        self.centerLayout.setContentsMargins(0, 0, 0, 0)
        self.centerLayout.setSpacing(0)
        self.centerLayout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)

        # Layout on the right side
        self.rightLayout = QHBoxLayout()
        self.rightLayout.setContentsMargins(0, 0, 0, 0)
        self.rightLayout.setSpacing(0)
        self.rightLayout.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.setLayout(self.mainLayout)

        self.leftWidget = QWidget()
        self.leftWidget.setLayout(self.leftLayout)
        self.centerWidget = QWidget()
        self.centerWidget.setLayout(self.centerLayout)
        self.rightWidget = QWidget()
        self.rightWidget.setLayout(self.rightLayout)

        self.mainLayout.addWidget(self.leftWidget)
        self.mainLayout.addWidget(self.centerWidget)
        self.mainLayout.addWidget(self.rightWidget)

    def setText(self, text):
        self.label.setText(text)

    def addActionLeft(self, action):
        toolButton = CreateFlatButton(action)
        self.addLeftItem(toolButton)

    def addActionCenter(self, action):
        toolButton = CreateFlatButton(action)
        self.addCenterItem(toolButton)

    def addActionRight(self, action):
        toolButton = CreateFlatButton(action)
        self.addRightItem(toolButton)

    def addLeftItem(self, widget):
        self.leftLayout.addWidget(widget)

    def addCenterItem(self, widget):
        self.centerLayout.addWidget(widget)

    def addRightItem(self, widget):
        self.rightLayout.addWidget(widget)
示例#48
0
class GuideIOWidget(QWidget):
    """

    """

    BUTTON_SIZE = 30

    def __init__(self, parent=None):
        super(GuideIOWidget, self).__init__(parent)

        self.buttons = {}

        self.setup_ui()

    def setup_ui(self):

        self.layout = QHBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.__add_button("write",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/write.png"),
                          self.__write,
                          "Write guide snapshot to disk")
        self.__add_button("read",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/read.png"),
                          self.__read,
                          "Read guide snapshot from disk")
        self.__add_button("rebuild",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/rebuild.png"),
                          self.__rebuild,
                          "Rebuild guide snapshot from disk")

        self.setLayout(self.layout)
        self.setWindowTitle("Guide IO")

        self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)

    def __add_button(self, object_name, icon_path, func, tooltip):
        """
        Add simple button to UI
        """

        button = QPushButton()
        button.setObjectName(object_name)
        button.setIcon(QIcon(QPixmap(icon_path)))
        button.setFixedSize(QSize(self.BUTTON_SIZE, self.BUTTON_SIZE))
        button.setIconSize(QSize(self.BUTTON_SIZE, self.BUTTON_SIZE))
        button.clicked.connect(func)

        button.setToolTip(tooltip)

        self.layout.addWidget(button)
        self.buttons[object_name] = button

    def sizeHint(self):
        return QSize(self.BUTTON_SIZE*len(self.buttons.keys()), self.BUTTON_SIZE)

    def __write(self):
        """
        Write a guide snapshot to disk
        """

        singleFilter = "Json (*.json)"
        path = cmds.fileDialog2(fileFilter=singleFilter, dialogStyle=2, fileMode=0)

        if path:
            logger.info("Writing guide snapshot: '%s'" % path[0])
            api.write(path[0])

    def __read(self):
        """
        Read a guide snapshot from disk
        """

        singleFilter = "Json (*.json)"
        path = cmds.fileDialog2(fileFilter=singleFilter, dialogStyle=2, fileMode=1)

        if path:
            logger.info("Reading guide snapshot: '%s'" % path[0])
            api.read(path[0])

    def __rebuild(self):
        """
        Rebuild a guide snapshot from disk
        """

        singleFilter = "Json (*.json)"
        path = cmds.fileDialog2(fileFilter=singleFilter, dialogStyle=2, fileMode=1)

        if path:
            logger.info("Reading guide snapshot: '%s'" % path[0])
            api.rebuild(path[0])
示例#49
0
class GuideWidget(QWidget):

    BUTTON_SIZE = 30

    def __init__(self, parent=None):
        super(GuideWidget, self).__init__(parent)

        self.buttons = {}

        self.setup_ui()

    def setup_ui(self):

        self.layout = QHBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.__add_button("create_guide",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/create.png"),
                          self.__create,
                          "Create guide")
        self.__add_button("remove_guide",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/remove.png"),
                          self.__remove,
                          "Remove selected guides")
        self.__add_button("set_parent",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/setParent.png"),
                          self.__set_parent,
                          "Set selected guides parent to be last selected")
        self.__add_button("add_child",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/addChild.png"),
                          self.__add_child,
                          "Add all selected guides as child to last selected")
        self.__add_button("remove_parent",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/removeParent.png"),
                          self.__remove_parent,
                          "Remove parent from selected guides")
        self.__add_button("duplicate",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/duplicate.png"),
                          self.__duplicate,
                          "Duplicate selected guide")
        self.__add_button("create_hierarchy",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/createHierarchy.png"),
                          self.__create_hierarchy,
                          "Create hierarchy out of selected guides")
        self.__add_button("cycle_aim",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/cycleAim.png"),
                          self.__cycle_aim,
                          "Cycle aim of selected guides")
        self.__add_button("compile",
                          os.path.join(os.path.dirname(__file__),
                                       "../icons/compile.png"),
                          self.__compile,
                          "Compile guides into joints")
        # self.__add_button("decompile",
        #                   os.path.join(os.path.dirname(__file__),
        #                                "../icons/decompile.png"),
        #                   self.__decompile,
        #                   "Decompile joints into guides")

        self.setLayout(self.layout)
        self.setWindowTitle("Guide tools")

        self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)

    def __add_button(self, object_name, icon_path, func, tooltip):
        """
        Add simple button to UI
        """

        button = QPushButton()
        button.setObjectName(object_name)
        button.setIcon(QIcon(QPixmap(icon_path)))
        button.setFixedSize(QSize(self.BUTTON_SIZE, self.BUTTON_SIZE))
        button.setIconSize(QSize(self.BUTTON_SIZE, self.BUTTON_SIZE))
        button.clicked.connect(func)

        button.setToolTip(tooltip)

        self.layout.addWidget(button)
        self.buttons[object_name] = button

    def sizeHint(self):
        return QSize(self.BUTTON_SIZE*len(self.buttons.keys()), self.BUTTON_SIZE)

    def __validate(self):
        """
        """

        guides = []
        selected = cmds.ls(sl=1)
        for sel in selected:
            try:
                guides.append(Guide.validate(sel))
            except Exception:
                pass

        return guides

    def __create(self):
        """
        Create a new guide
        """

        global CREATE_GUIDE_DIALOG
        CREATE_GUIDE_DIALOG = CreateGuideDialog()
        CREATE_GUIDE_DIALOG.exec_()

        position, description, index = CREATE_GUIDE_DIALOG.results
        if all([position, description, isinstance(index, int)]):
            _guide = guide.create(position, description, index)
            cmds.select(_guide.node, r=True)

    def __remove(self):
        """
        Remove guide from scene
        """

        cmds.undoInfo(openChunk=True)

        guides = self.__validate()

        for _guide in guides:
            guide.remove(_guide)

        cmds.undoInfo(closeChunk=True)

    def __set_parent(self):
        """
        Set all selected guides to have the same parent
        """

        guides = self.__validate()

        if len(guides) >= 2:

            children = guides[:-1]
            parent = guides[-1]
            for child in children:
                guide.set_parent(child, parent)

            cmds.select(parent.node, r=True)

    def __add_child(self):
        """
        Add all selected guides as child to first selected
        """

        guides = self.__validate()

        if len(guides) >= 2:

            children = guides[:-1]
            parent = guides[-1]
            for child in children:
                guide.add_child(parent, child)

            cmds.select([g.node for g in children], r=True)

    def __remove_parent(self):
        """
        Remove parent from guide
        """

        guides = self.__validate()

        if guides:
            for _guide in guides:
                _guide.remove_parent()

    def __duplicate(self):
        """
        Duplicate selected guides hierarchy
        """

        guides = self.__validate()

        top = []
        for _guide in guides:

            nodes = guide.duplicate(_guide, hierarchy=True)
            top.append(nodes[0])

        # Select top guides
        cmds.select(top, r=True)

    def __create_hierarchy(self):
        """
        Create hierarchy from sequentially selected guides 
        """

        guides = self.__validate()

        last = None
        while len(guides):
            parent = last or guides.pop(0)
            child = guides.pop(0)

            last = child

            guide.set_parent(child, parent)

    def __cycle_aim(self):
        """
        Cycle selected guides aim index to next
        in enum. Skips world/local aims.
        """

        guides = self.__validate()

        for _guide in guides:
            aims = cmds.attributeQuery("aimAt", node=_guide.node, listEnum=True)[0].split(":")
            current_index = cmds.getAttr("%s.aimAt" % _guide.node)
            index = 1

            if not current_index == (len(aims) - 1):
                index = (current_index + 1)

            cmds.setAttr("%s.aimAt" % _guide.node, index)

    def __decompile(self):
        """
        """

        guide.decompile()

    def __compile(self):
        """
        """

        guide.compile()
示例#50
0
    def _set_widget_buttons(self, row):
        # mainlog.debug("_set_widget_buttons({})".format(row))

        doc = self.model.object_at(row)

        p_download = make_tool_button(
            "appbar.page.download.png",
            "download{}".format(self.button_id_counter))
        p_download.clicked.connect(self.signal_mapper_save_a_copy_button.map)
        self.signal_mapper_save_a_copy_button.setMapping(
            p_download, self.button_id_counter)

        # FIXME Json calls should produce rela objects and not tuples or Frozen,...
        has_reference = False
        try:
            has_reference = doc.reference
        except:
            pass

        # FIXME HAchkish this is really valid for templates, and not super-really-valid for mere documents
        if not has_reference:
            p_delete = make_tool_button("appbar.page.delete.png")
            p_delete.clicked.connect(self.signal_mapper_close_button.map)
            self.signal_mapper_close_button.setMapping(p_delete,
                                                       self.button_id_counter)

        # I've already tested several things here
        # use a qss style, setting strecth, borders, contentsmargins, etc.
        # But for some reasons, when I test the widget in a dialog
        # the space between buttons is wide. If I run the widget in Horse
        # (that is, in normal conditions) then the display works as exepcted
        # (buttons close together and not wide apart)

        z = QWidget()
        layout = QHBoxLayout()
        layout.setSpacing(0)
        # layout.setStretch(0,0)
        # layout.setStretch(1,0)
        layout.setContentsMargins(0, 0, 0, 0)
        # layout.addWidget(p_open)

        p_download.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(p_download)

        if not has_reference:
            p_delete.setContentsMargins(0, 0, 0, 0)
            layout.addWidget(p_delete)
        # z.setMinimumHeight(64)

        z.setLayout(layout)

        # QTableView takes ownership of the widget (see Qt doc.)
        self.view.setIndexWidget(
            self.model.index(row,
                             self.model.columnCount() - 1), z)

        #doc.button_id = self.button_id

        # A bit complicated, but that's the simplest way
        # to tie an in-table button to some data
        self.button_data[self.button_id_counter] = (doc.document_id)
        self.button_id_counter += 1
示例#51
0
class EditorWindow(QMainWindow):
    """initialize editor"""
    def __init__(self, tixi, xmlFilename, cpacs_scheme=Config.path_cpacs_21_schema):
        super(EditorWindow, self).__init__()   
        
        self.cur_file_path = ""
        self.cur_schema_path = ""
        
        self.setupEditor()
        self.setupButtonMenu()
        self.setupSearchBox()
        self.setupStatusbar()
        self.setupMenubar()
        self.setupNumbar()
        
        self.popUpWidget = None
        
        self.flag_layout = False
       
        self.hbox = QHBoxLayout()
        self.hbox.setSpacing(0)
        self.hbox.setContentsMargins(0,0,0,0)
        self.hbox.addWidget(self.number_bar)
        self.hbox.addWidget(self.editor)         
        
        self.layout = QGridLayout()
        
        self.layout.addWidget(self.searchbox,       0, 0, 1, 4)
        self.layout.addWidget(self.button1,         0, 4, 1, 1)
        self.layout.addWidget(self.button2,         0, 5, 1, 1)
        self.layout.addLayout(self.hbox,            2, 0, 1, 8)       
        self.layout.addWidget(self.fontsizeSpinBox, 0, 6, 1, 1)
        self.layout.addWidget(self.label1,          0, 7, 1, 1)
       
        self.window = QWidget()
        self.window.setLayout(self.layout) 

        self.setWindowTitle('Simple XML editor')
        self.setCentralWidget(self.window)
        self.resize(800, 800)
        self.show()       

        self.tixi = tixi
        self.loadFile(xmlFilename, cpacs_scheme) 

    '''
    loads cpacs file and validates it against the cpacs_schema
    @param xmlFilename: input file
    @param cpacs_scheme: validation scheme
    '''
    def loadFile(self, xmlFilename=None, cpacs_scheme=Config.path_cpacs_21_schema):
        if xmlFilename and cpacs_scheme :
            try:
                self.tixi.open(xmlFilename)
                #self.tixi.openDocument(xmlFilename) 
                #self.tixi.schemaValidateFromFile(cpacs_scheme)
                self.editor.setPlainText(self.tixi.exportDocumentAsString())
                self.cur_file_path = xmlFilename
                self.cur_schema_path = cpacs_scheme  
            except TixiException as e:  
                self.statusBar().showMessage('CPACS ERROR: ' + e.error)

    '''
    update the dictionary by the cpacs scheme
    @param path_dict: path to directory
    @param path_scheme: path to cpacs_scheme
    '''
    def updatedictionary(self, path_dict=Config.path_code_completion_dict, path_scheme=Config.path_cpacs_21_schema):
        found       = False
        olddict      = open(path_dict)
        scheme_file = open(path_scheme, 'r')
        
        with open(path_dict, "a") as newdict :
            for line in scheme_file :
                word = re.search("(?<=\<xsd:complexType name=\").*(?=\"\>)", line)
                if word != None :
                    for tmp in olddict : 
                        if tmp == word.group(0) +"\n" :
                            found = True
                            break
                    if(not found) :
                        newdict.write(word.group(0)+"\n")
                        olddict.seek(0)
                    found = False
            
        olddict.close()
        newdict.close()
        scheme_file.close()            

    '''
    validate xml file and write result to statusBar
    '''
    def validate(self):
        try:
            etree.fromstring(str(self.editor.toPlainText()))
            self.statusBar().showMessage("Valid XML")
        except etree.XMLSyntaxError as e:
            if e.error_log.last_error is not None:
                msg  = e.error_log.last_error.message
                line = e.error_log.last_error.line
                col  = e.error_log.last_error.column
                self.statusBar().showMessage("Invalid XML: Line %s, Col %s: %s"%(line,col,msg))
        except:
            self.statusBar().showMessage("Invalid XML: Unknown error") 

    '''
    close and cleanup tixi
    '''
    def __del__(self):
        pass
        #self.tixi.close()
        #self.tixi.cleanup() 

    '''
    set and connect the search buttons
    '''
    def setupButtonMenu(self):
        self.button1         = QPushButton("previous" )
        self.button2         = QPushButton("next" )
        self.label1          = QLabel("font")
        self.fontsizeSpinBox = QSpinBox()
        
        self.button1.hide()
        self.button2.hide()
        self.label1.hide()
        self.fontsizeSpinBox.hide()

        self.button1.clicked.connect(self.fire_search_backward)
        self.button2.clicked.connect(self.fire_search_foreward)
         
        self.fontsizeSpinBox.setRange(4, 30)
        self.fontsizeSpinBox.setSingleStep(1)
        self.fontsizeSpinBox.setSuffix('pt')
        self.fontsizeSpinBox.setValue(10)        
        self.fontsizeSpinBox.valueChanged.connect(self.setfontsize)         
    
    def setfontsize(self, value):
        self.font.setPointSize(value)
        self.editor.setFont(self.font)
                
    def setupEditor(self):
        self.font = QFont()
        self.font.setFamily('Courier')
        self.font.setFixedPitch(True)
        self.font.setPointSize(10)
        
        self.editor = EditorCodeCompletion(Config().path_code_completion_dict)       
        self.editor.setFont(self.font)
        self.editor.setTabStopWidth(20)
        self.editor.setAcceptRichText(False)
        self.editor.setLineWrapMode(QTextEdit.NoWrap)
        self.editor.textChanged.connect(self.validate)
        
        self.highlighter = Highlighter(self.editor.document())
    
    def setupNumbar(self):
        self.number_bar = NumberBar()
        self.number_bar.setTextEdit(self.getStates())
        self.editor.cursorPositionChanged.connect(self.fireUpdateNumbar)        
        self.connect(self.editor.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.fireUpdateNumbar)  
        #self.editor.verticalScrollBar.valueChanged.connect(self.fireUpdateNumbar)

    def setupStatusbar(self):
        self.lineNumber = -1
        self.colNumber = -1
        self.m_statusRight = QLabel("row: " + str(self.lineNumber) + ", col:"  + str(self.colNumber), self)
        self.statusBar().addPermanentWidget(self.m_statusRight, 0) 

    def setupSearchBox(self):
        self.searchbox = SearchField() 
        self.searchbox.hide()     
        
    def setupMenubar(self):
        commentAction = QAction('Comment', self)
        commentAction.setShortcut('Ctrl+K')
        commentAction.setStatusTip('Comment Block')
        commentAction.triggered.connect(self.fireComment)
        
        uncommentAction = QAction('Uncomment', self)
        uncommentAction.setShortcut('Ctrl+Shift+K')
        uncommentAction.setStatusTip('Comment Block')
        uncommentAction.triggered.connect(self.fireUnComment)        
                        
        searchAction = QAction('search', self)
        searchAction.setShortcut('Ctrl+F')
        searchAction.setStatusTip('search')
        searchAction.triggered.connect(self.fireSearchView)     
        
                        
        newAction = QAction('New', self)
        newAction.setShortcut('Ctrl+N') 
        newAction.setStatusTip('creats empty cpacs-file')
        newAction.triggered.connect(self.fireNewAction)                       
                        
        self.updateAction = QAction('Update', self)
        self.updateAction.setShortcut('Ctrl+U')
        self.updateAction.setStatusTip('Update CPACS')
        self.updateAction.triggered.connect(self.fireUpdate)

        revertAction = QAction('Revert', self)
        revertAction.setShortcut('Ctrl+R')
        revertAction.triggered.connect(self.fireRevert)        

        clearAction = QAction('Clear', self)
        clearAction.setStatusTip('Clear Editor')
        clearAction.triggered.connect(self.editor.clear)

        numbarAction = QAction('Line Number', self)
        numbarAction.triggered.connect(self.fireSwitchLayout)                 

        self.xpathAction = QAction('Current XPath', self)
        self.xpathAction.triggered.connect(self.getCursorXPath)  

        link_to_node_YesAction = QAction('yes', self)
        link_to_node_YesAction.triggered.connect(self.dummyFuction)  

        link_to_node_NoAction = QAction('no', self)
        link_to_node_NoAction.triggered.connect(self.dummyFuction)  

        toolXAction = QAction('Tool X',self)
        toolXAction.triggered.connect(self.fireToolX)

        menubar = self.menuBar()
        filemenu = menubar.addMenu("File")
        filemenu.addAction(newAction)
        filemenu.addAction(self.updateAction) 
        filemenu.addAction(revertAction)         
        sourcemenu = menubar.addMenu("Source")  
        sourcemenu.addAction(commentAction)  
        sourcemenu.addAction(uncommentAction)
        sourcemenu.addAction(searchAction)
        editormenu = menubar.addMenu("Editor")
        editormenu.addAction(clearAction) 
        editormenu.addSeparator()
        editormenu.addAction(numbarAction)
        editormenu.addAction(self.xpathAction)
        editormenu_child1 = editormenu.addMenu('Link to node')
        editormenu_child1.addAction(link_to_node_YesAction)
        editormenu_child1.addAction(link_to_node_NoAction)
        toolmenu = menubar.addMenu("Tools")
        toolmenu.addAction(toolXAction)

        self.editor.setContextMenuPolicy(Qt.CustomContextMenu)
        self.editor.customContextMenuRequested.connect(self.showMenu)
        #self.editor.connect(self.editor, SIGNAL( "customContextMenuRequested(QPoint)" ), self.showMenu )

    def showMenu( self, pos ):
        """ Show a context menu for the active layer in the legend """
        menu = self.editor.createStandardContextMenu()
        menu.addAction(self.xpathAction)
        menu.exec_(QtCore.QPoint( self.mapToGlobal( pos ).x() + 5, self.mapToGlobal( pos ).y() )) 
            

    def fireUpdateNumbar(self):
        self.updateLineNumber()
        self.number_bar.update()

    def dummyFuction(self):
        print ("not implemented yet")
  
    def getStates(self):
        self.stats = { "searchbox":self.searchbox, "editor":self.editor}
        return self.stats    
        
    ''' find previous button '''    
    def fire_search_backward(self):
        self.editor.find(self.searchbox.text(), QTextDocument.FindBackward)  
        self.searchbox.setFocus()
        
    ''' find next button '''    
    def fire_search_foreward(self):
        
        #print self.tixi.getNumberOfChilds('/cpacs/vehicles/aircraft/model[@uID="Aircraft1"]/wings/wing[@uID="Aircraft1_Wing1"]/transformation[@uID="Aircraft1_Wing1_Transf"]/scaling[@uID="Aircraft1_Wing1_Transf_Sca"]/z')
        
        searchList = list(filter(lambda a : a!='',  self.searchbox.text().split('/')))
        if len(searchList) == 1 :
            if self.editor.find(searchList[0]) : 
                pass
            elif not self.editor.find(searchList[0], QTextDocument.FindBackward):
                QMessageBox.about(self, "error", "String %s not found" % (searchList[0]))
            else :
                self.editor.moveCursor(QTextCursor.Start)
                self.editor.find(searchList[0])
        else :
            self.searchXPath(self.searchbox.text(), searchList)
                
        self.searchbox.setFocus()     
      
    # test  
    # /cpacs/vehicles/aircraft/model/wings/wing/sections/section
    def searchXPath(self, path, searchList):
        try:
            if self.tixi.xPathEvaluateNodeNumber(path) > 1 :
                QMessageBox.about(self, "error", "XPath %s not unique" % path)
                return
                
            self.editor.moveCursor(QTextCursor.Start)
            
            found = True

            # search index snd loop
            j = 0
        
            # search backwards for uid 
            for i in range(len(searchList)-1, -1, -1) :
                if '[' in searchList[i] :    
                    # get value in brackets : [x] --> x
                    uid = re.search(r'\[(.*)\]', searchList[i]).group(1)
                    uid = self.__transToSearchUid(searchList[:i+1], uid)
                    
                    found = self.editor.find(uid)
                    j = i+1
                    break
                
            # search forward for all nodes after last uid
            while found and j < len(searchList) :
                found = self.editor.find('<'+searchList[j])
                j += 1
            if not found :
                QMessageBox.about(self, "error", "XPath %s not found" % path)
        except TixiException :
            QMessageBox.about(self, "error", "XPath %s not found" % path)


    def __transToSearchUid(self, path_list, uid):
        try: 
            int(uid)
            path = ""
            for p in path_list : path = path + '/' + p 
            return self.tixi.getTextAttribute(path , 'uID')
        except ValueError: 
            return uid.replace('@', '')

    def getCursorXPath(self):
        start_pos = self.editor.textCursor().position()

        tag , tag_pos , isCursorInTag = self.getTagNameAtCursor()
        
        _,xpath_idx, xpath_uid = self.__findXPath_rec('/cpacs', '/cpacs' , tag, tag_pos)  
        
        if not isCursorInTag:
            xpath_idx = self.__strRemoveReverseToChar(xpath_idx, '/')
            xpath_uid = self.__strRemoveReverseToChar(xpath_uid, '/')
 
        self.__setCursorToPostion(start_pos)
        self.__startXPathPopUp(xpath_idx, xpath_uid)
        
        
    def getTagNameAtCursor(self):
        '''
        @return: name of tag , position of tag , cursor is btw open and closing tag 
        '''
        self.editor.find('<', QTextDocument.FindBackward)
        isClosingTag , fst_tag   = self.__getTagName()

        pos = self.editor.textCursor().position()
        
        if isClosingTag :
            # find open tag of this closing tag
            self.editor.find('<'+fst_tag, QTextDocument.FindBackward)
            pos = self.editor.textCursor().position()
            
            return fst_tag , pos , False
        else:
            return fst_tag , pos , True


    def __getTagName(self):
        tc = self.editor.textCursor()
        tc.select(QTextCursor.WordUnderCursor)
        
        tx = tc.selectedText()  
        isClosingTag = False
        
        if "</" in tx :
            # select next word
            tc.select(QTextCursor.WordUnderCursor)
            tx = tc.selectedText()
            isClosingTag = True
        
        return isClosingTag , "" if "<" in tx else tx
        

    def __findXPath_rec(self, xpath_idx, xpath_uid, search, pos):
        nodes = self.__getChildNodesIdxTuple(xpath_idx)
        
        for (node, idx) in nodes:
            if node != '#text' :
                new_xpath_idx, new_xpath_uid = self.__createNewXPath(xpath_idx, xpath_uid, node, idx)
                if search == node and self.isNodeAtSearchedTagPosition(new_xpath_uid, pos) :
                    print ("gefunden" , new_xpath_idx)
                    return True, new_xpath_idx , new_xpath_uid
                else:
                    flag , res_idx, res_uid = self.__findXPath_rec(new_xpath_idx, new_xpath_uid, search, pos)
                    if flag : return True, res_idx, res_uid
        return False , xpath_idx , xpath_uid


    def __getChildNodesIdxTuple(self, xpath):
        n = self.tixi.getNumberOfChilds(xpath) + 1
        node_list = list(map(lambda i : self.tixi.getChildNodeName(xpath, i), range(1,n)))
        
        res = []
        for j in range(len(node_list)) :
            cnt = 1
            for k in range(j):
                if node_list[k] == node_list[j] : 
                    cnt = cnt + 1
            res.append((node_list[j],cnt))
        
        return res
    

    def __createNewXPath(self, xpath_idx, xpath_uid, node, idx):
        path_idx = xpath_idx + '/' + node
        path_uid = xpath_uid + '/' + node

        try :
            uID = self.tixi.getTextAttribute(path_idx + '[' + str(idx) + ']', 'uID')
            path_idx = path_idx + '[' + str(idx) + ']'
            path_uid = path_uid+'[@uID="' + uID + '"]'
            
        except TixiException:
            pass # e.error == 'ATTRIBUTE_NOT_FOUND
            
        return path_idx , path_uid


    
    def isNodeAtSearchedTagPosition(self, xpath, pos):
        '''
        @param xpath: xpath with uids (doesn't work with indices)
        @param param: 
        '''
        self.editor.moveCursor(QTextCursor.Start)
        
        # split string at / and remove all empty strings
        l = list(filter(lambda x : x != '' , xpath.split('/')))
        
        # search index snd loop
        j = 0
        
        # search backwards for uid 
        for i in range(len(l)-1, -1, -1) :
            if '[' in l[i] :    
                # get value in brackets : [x] --> x
                uid = re.search(r'\[@(.*)\]', l[i]).group(1)
                self.editor.find(uid)
                
                j = i+1
                break
        
        # search forward for all nodes after last uid
        while j < len(l) :
            self.editor.find('<'+l[j])
            j += 1

        return pos <= self.editor.textCursor().position()


    def __setCursorToPostion(self, pos):
        tc = self.editor.textCursor()
        tc.setPosition(pos)
        self.editor.setTextCursor(tc)

    def __startXPathPopUp(self, xpath_idx, xpath_uid):
        self.popUpWidget = XPathDialog(xpath_idx, xpath_uid) 

        self.setEnabled(False)
        self.popUpWidget.closeAct.triggered.connect(self.__resetPopUpWidget)
        
        self.popUpWidget.show()  


    def updateLineNumber(self): 
        '''
        sets the line and column number
        '''
        self.lineNumber = self.editor.textCursor().blockNumber() + 1
        self.colNumber = self.editor.textCursor().columnNumber() + 1
        self.m_statusRight.setText("row: " + str(self.lineNumber) + ", col:"  + str(self.colNumber))           

       
    def highlightCurrentLine(self) :
        '''
        highlight line under cursor
        ''' 
        extraSelections = []
        selection = QTextEdit.ExtraSelection()
        lineColor = QColor(255, 250, 205)
        selection.format.setBackground(lineColor)
        selection.format.setProperty(QTextFormat.FullWidthSelection, True)
        selection.cursor = self.editor.textCursor()
        selection.cursor.clearSelection()
        extraSelections.append(selection)
        self.editor.setExtraSelections(extraSelections)
        self.editor.setFocus()  
 
    #TODO: implemnt
    def fireUpdate(self):
        print ('dummy function - update the model')
        text_file = open(Config.path_cpacs_tmp_file, "w")
        text_file.write(self.editor.toPlainText())
        text_file.close()
        
        
        #self.tixi.saveDocument(Config.path_cpacs_tmp_file)
      # '../cpacs_files/temp.xml'
        

    def fireRevert(self):
        '''
        reloads cpacs file if not updated yet
        '''
        if(self.cur_file_path and self.cur_schema_path) :
            self.loadFile(self.cur_file_path, self.cur_schema_path)
        else :
            QMessageBox.about(self, "error", "CPACS-File or Validation-Schema not available")
            

    def fireSwitchLayout(self): 
        '''
        function to show or hide line numbers
        '''
        if(self.flag_layout) :
            self.number_bar.flag_show_numbers = True
            self.update()
        else :  
            self.number_bar.flag_show_numbers = False
            self.update()
        self.flag_layout = not self.flag_layout 
    
    def fireNewAction(self):
        '''
        opens new file input form   
        '''          
        self.setEnabled(False)
        self.popUpWidget = NewFileDialog()
        self.popUpWidget.buttonBox.accepted.connect(self.__createNewCpacsFile)
        self.popUpWidget.buttonBox.rejected.connect(self.__resetPopUpWidget)
        self.popUpWidget.closeAct.triggered.connect(self.__resetPopUpWidget)
        self.popUpWidget.show()
   
    def fireToolX(self):
        self.popUpWidget = ToolX("X-Tool", self.tixi)
        self.setEnabled(False)
        self.popUpWidget.buttonBox.accepted.connect(self.__resetPopUpWidget)
        self.popUpWidget.buttonBox.rejected.connect(self.__resetPopUpWidget)
        # closeAct for pressing X to close window
        self.popUpWidget.closeAct.triggered.connect(self.__resetPopUpWidget)
        self.popUpWidget.show()        
       
    def __createNewCpacsFile(self):
        '''
        closes all documents and creates new empty cpacs temporary file   
        '''        
        idict = self.popUpWidget.fire_submitInput()
        self.tixi.closeAllDocuments()
        self.tixi.create('cpacs')
        self.tixi.addCpacsHeader(idict['name'], idict['creator'], idict['version'], idict['description'], idict['cpacsVersion'])
        self.tixi.saveDocument(Config.path_cpacs_tmp_file)
        self.loadFile(Config.path_cpacs_tmp_file)
        self.__resetPopUpWidget()
        
    def __resetPopUpWidget(self):
        self.popUpWidget.close()
        self.popUpWidget = None    
        self.setEnabled(True)
    
    
    def fireComment(self):  
        '''
        inserts open respective closing tag before and after a selected text. 
        '''
        tc = self.editor.textCursor()

        tc.beginEditBlock()
        tc.setPosition(self.editor.textCursor().selectionStart())
        tc.insertText("<!--")
        
        tc.setPosition(self.editor.textCursor().selectionEnd())
        tc.insertText("-->")  
        tc.endEditBlock()      


    def fireUnComment(self):
        '''
        removes open respective closing tag before and after a selected text. 
        '''        
        tc = self.editor.textCursor()
        selectTxt = tc.selectedText()
        
        if selectTxt.find('<!--') != -1 : 
            if selectTxt.rfind('-->') != -1 :
                selectTxt = selectTxt.replace('<!--', '', 1)
                selectTxt = self.__rreplace(selectTxt, '-->' , '', 1)
                tc.insertText(selectTxt)
            else:
                QMessageBox.about(self, "error", "no open tag (%s) in selection" % ('-->')) 
        else:
            QMessageBox.about(self, "error", "no close tag (%s) in selection" % ('<!--')) 
        

    def fireSearchView(self):
        '''
        show and hide searchbox and buttons
        '''        
        if self.searchbox.isFocused() :
            self.searchbox.hide()
            self.button1.hide()
            self.button2.hide()
            self.label1.hide()
            self.fontsizeSpinBox.hide()
        else :
            self.searchbox.show()
            self.button1.show()
            self.button2.show()
            self.label1.show()
            self.fontsizeSpinBox.show()
            self.searchbox.setFocus()

    def keyPressEvent(self,event):
        '''
        handle for searching strings by pressing enter key
        '''        
        if self.searchbox.isFocused() and event.key() == Qt.Key_Return :            
            self.fire_search_foreward()   
   
    # ======================================================================================================================
    # utilities
    # ======================================================================================================================
    def __strRemoveReverseToChar(self, s, c):
        return self.__rm_rec(s, c)
    
    def __rm_rec(self, s, c):
        if s == "" :
            return ""
        elif s[-1] == c :
            return s[:-1]
        else :
            return self.__rm_rec(s[:-1], c)     
    
    def __rreplace(self, s, old, new, occurrence):
        '''
        reverse string replace function
        @param s: source string
        @param old: char to be replaced
        @param new: new char 
        @param occurrence: only the given count occurrences are replaced.
        ''' 
        li = s.rsplit(old, occurrence)
        return new.join(li)   
class ToolbarWidget(QWidget):
	"""
	ToolbarWidget
	"""

	def __init__(self):
		super(ToolbarWidget, self).__init__()

		# Make sure the widget expands over the whole toolbar
		self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

		# Create main layout that will contain the layouts for each section
		self.mainLayout = QHBoxLayout()
		self.mainLayout.setContentsMargins(0, 0, 0, 0)
		self.mainLayout.setSpacing(0)

		# Layout on the left side
		self.leftLayout = QHBoxLayout()
		self.leftLayout.setContentsMargins(0, 0, 0, 0)
		self.leftLayout.setSpacing(0)
		self.leftLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

		# Layout in the center
		self.centerLayout = QHBoxLayout()
		self.centerLayout.setContentsMargins(0, 0, 0, 0)
		self.centerLayout.setSpacing(0)
		self.centerLayout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)

		# Layout on the right side
		self.rightLayout = QHBoxLayout()
		self.rightLayout.setContentsMargins(0, 0, 0, 0)
		self.rightLayout.setSpacing(0)
		self.rightLayout.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

		self.setLayout(self.mainLayout)

		self.leftWidget = QWidget()
		self.leftWidget.setLayout(self.leftLayout)
		self.centerWidget = QWidget()
		self.centerWidget.setLayout(self.centerLayout)
		self.rightWidget = QWidget()
		self.rightWidget.setLayout(self.rightLayout)

		self.mainLayout.addWidget(self.leftWidget)
		self.mainLayout.addWidget(self.centerWidget)
		self.mainLayout.addWidget(self.rightWidget)

	def setText(self, text):
		self.label.setText(text)

	def addActionLeft(self, action):
		toolButton = CreateFlatButton(action)
		self.addLeftItem(toolButton)

	def addActionCenter(self, action):
		toolButton = CreateFlatButton(action)
		self.addCenterItem(toolButton)

	def addActionRight(self, action):
		toolButton = CreateFlatButton(action)
		self.addRightItem(toolButton)

	def addLeftItem(self, widget):
		self.leftLayout.addWidget(widget)

	def addCenterItem(self, widget):
		self.centerLayout.addWidget(widget)

	def addRightItem(self, widget):
		self.rightLayout.addWidget(widget)