Esempio n. 1
0
class TreeviewWidgetSelectProve(QMainWindow):

    def __init__(self):
        super(TreeviewWidgetSelectProve, self).__init__()
        ui_file_path = os.path.join(
            '/home/n130s/link/ROS/groovy_quantal/catkin_ws/src/rqt_prove',
            'resource', 'treeview_2.ui')

        loader = QUiLoader(self)
        ui_file = QFile(ui_file_path)
        self._widget_top = loader.load(ui_file, self)

        self._std_model = QStandardItemModel()
        self._rootitem = self._std_model.invisibleRootItem()

        item_r_1 = QStandardItem("r1")

        self._rootitem.appendRow(item_r_1)
        # self._rootitem.appendRow(item_r_2)
        print('_rootitem index={}'.format(self._rootitem.index()))

        self._treeview = self._widget_top.findChild(QTreeView, '_treeview')
        self._treeview.setModel(self._std_model)
        self.selectionModel = self._widget_top._treeview.selectionModel()

        print('del/sel?\tde/sel index\tde/sel.row\tde/sel.dat\tparent\tinternal id')
        self._widget_top.show()
class LoaduiProve(QWidget):

    def __init__(self):
        super(LoaduiProve, self).__init__()
        print ('QT_BINDING=' + QT_BINDING)
        ui_file_path = os.path.join(
            '/home/n130s/link/ROS/groovy_quantal/catkin_ws/src/rqt_prove',
            'resource', 'treeview_3.ui')

        #uiw = loadUi(ui_file_path)
        uiw = loadUi(ui_file_path,
               #{'LoaduiProve': LoaduiProve,
               {'CustomQTableview': CustomQTableview,
               'CustomQTreeview': CustomQTreeview})

        self._std_model = QStandardItemModel()
        self._rootitem = self._std_model.invisibleRootItem()

        uiw._treeview.setModel(self._std_model)
        self.selectionModel = self._treeview.selectionModel()

        self.show()
Esempio n. 3
0
    def testClear(self):

        model = QStandardItemModel()
        root = model.invisibleRootItem()
        model.clear()
        self.assertFalse(shiboken.isValid(root))
Esempio n. 4
0
 def __init__(self,parent=None,title='Macro editor'):
     # This class derivates from a Qt Widget so we have to call
     # the class builder ".__init__()"
     QWidget.__init__(self)
     # "self" is now a Qt Widget, then we instantiate the user interface
     # generated with QtDesigner and call it self.ui
     self.ui = Ui_Macro_editor()
     # Now we have to feed the GUI building method of this object (self.ui)
     # with a reference to the Qt Widget where it will appear, i.e. itself
     # but the elements of the GUI will actually be children of the GUI (i.e of self.ui not of self)
     self.ui.setupUi(self)
     self.setWindowTitle(title)
     
     # List the Macro command that will be loaded and available
     # into the Macro editor.
     # Once you have created a new Macro command class in this file
     # you must add it in this list for it to be available in 
     # the Macro editor.
     # You may also remove commands from this list if you want to deactivate them
     self.valid_list_of_commands=[
                                 AngleCommand(),
                                 CommentsCommand(),
                                 WaitCommand(),
                                 WaitForEpoch(),
                                 SetFieldCommand(),
                                 WaitForHStableCommand(),
                                 WaitForMeasureCommand(),
                                 SetPersistFieldCommand(),
                                 SetTempCommand(),
                                 SetHeaterCommand(),
                                 WaitForTStableCommand(),
                                 SetTempVTICommand(),
                                 SetVTIHeaterCommand(),
                                 SetSaveFileCommand(),
                                 StartMeasureCommand(),
                                 StopMeasureCommand(),
                                 EmailCommand(),
                                 EmailFileCommand(),
                                 EmailDirCommand(),
                                 SetICommand(),
                                 SetVCommand()]        
     
     ### Dirty FIX: the macro editor is in a layout and a group box which somehow
     ### put it way down the list of children, so we need the 6th order parent of that to get to the main !
     ##self.main=self.parent().parent().parent().parent().parent().parent()
     ### FIXED:the main class now simply gives a link to itself when it instantiates the Macro Editor
     ### this has the added benefit of keeping track of which class may use the main
     self.main=parent
     self.macro_isActive=False
     
     self.macro_timer = QTimer()
     #Use a single shot timer in between commands
     #otherwise it may fire again before the task is completed
     self.macro_timer.setSingleShot(True)
     self.macro_timer.timeout.connect(self.next_command)
            
     #initiate syntax highlighting for the macro editor
     self.highlighter = MacroHighlighter(self.ui.macro_textbox.document(),self.valid_list_of_commands)
     
     #update the list of available macro commands in the user interface
     model=QStandardItemModel()
     parentItem = model.invisibleRootItem()
     for command in self.valid_list_of_commands:
         parentItem.appendRow(QStandardItem(command.label))
     self.ui.macrocommandtree.setModel(model)
    def testClear(self):

        model = QStandardItemModel()
        root = model.invisibleRootItem()
        model.clear()
        self.assertFalse(shiboken.isValid(root))