コード例 #1
0
    def initWidget(self):
        mainBox = QVBoxLayout(self)

        mainBox.addWidget(QLabel("Press " + self.action.shortcut.toString() + " to " +\
                                 self.action.text))
        self.widgets = [_GraspMode(self), _PlacementMode(self)]
        mainBox.addWidget(self.widgets[0])
        mainBox.addWidget(self.widgets[1])
        self.widgets[1].hide()
コード例 #2
0
    def createWidget(self):
        box = QVBoxLayout(self)

        text = "You are in placement mode.\n" +\
               "In this mode you can place an object\non an environment surface.\n" +\
               "The object and the environment must\nhave contact surface defined.\n" +\
               "Press :\n" +\
               "  - " + self.action.shortcut.toString() + " to " + self.action.text + "\n\n" +\
               "First selected body will be\nconsidered as the object.\n" +\
               "Second selected body will be\nconsidered as the environment.\n" +\
               "The object will be place where\nyou clicked on the environment."
        box.addWidget(QLabel(text, self))
コード例 #3
0
    def __init__(self, parent, withToolbar = False):
        super(MatplotlibWidget, self).__init__ (parent)

        box = QVBoxLayout(self)
        ## The matplotlib figure
        self.figure = Figure(figsize=(5,5), dpi=96)
        ## The figure canvas
        self.canvas = FigureCanvasQTAgg (self.figure)
        box.addWidget(self.canvas)

        if withToolbar:
            self.toolbar = NavigationToolbar2QT(self.canvas, parent, False)
            box.addWidget(self.toolbar)    
コード例 #4
0
    def __init__(self, parent, withToolbar=False):
        super(MatplotlibWidget, self).__init__(parent)

        box = QVBoxLayout(self)
        ## The matplotlib figure
        self.figure = Figure(figsize=(5, 5), dpi=96)
        ## The figure canvas
        self.canvas = FigureCanvasQTAgg(self.figure)
        box.addWidget(self.canvas)

        if withToolbar:
            self.toolbar = NavigationToolbar2QT(self.canvas, parent, False)
            box.addWidget(self.toolbar)
コード例 #5
0
ファイル: dialogs.py プロジェクト: exp111/pyTSon-Scripts
class MultiInputDialog(QDialog):
    def __init__(self, title, label1, label2, parent=None):
        super().__init__(parent)
        self.setWindowTitle(title)
        self.lay = QVBoxLayout(self)

        self.lay1 = QHBoxLayout()
        self.label1 = QLabel(label1, self)
        self.lay1.addWidget(self.label1)
        self.input1 = QLineEdit(self)
        self.lay1.addWidget(self.input1)
        self.lay.addLayout(self.lay1)

        self.lay2 = QHBoxLayout()
        self.label2 = QLabel(label2, self)
        self.lay2.addWidget(self.label2)
        self.input2 = QLineEdit(self)
        self.lay2.addWidget(self.input2)
        self.lay.addLayout(self.lay2)

        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
                                self)
        bbox.connect("accepted()", self.accept)
        bbox.connect("rejected()", self.reject)
        self.lay.addWidget(bbox)

    def cleanup(self):
        self.lay1.delete()
        self.lay2.delete()

    @staticmethod
    def getTexts(title, label1, label2, text1="", text2="", parent=None):
        dlg = MultiInputDialog(title, label1, label2, parent)

        dlg.label1.setText(label1)
        dlg.input1.setText(text1)
        dlg.label2.setText(label2)
        dlg.input2.setText(text2)

        if dlg.exec_() == QDialog.Accepted:
            ret1 = dlg.input1.text
            ret2 = dlg.input2.text

            dlg.cleanup()
            dlg.delete()

            return (True, ret1, ret2)
        else:
            return (False, "", "")
コード例 #6
0
    def createWidget(self):
        box = QVBoxLayout(self)
        self.text = "You're in grasp/pregrasp mode.\n" +\
        "In this mode, you can select two object.\n" +\
        "To do so, click on it.\n" +\
        "Once you choose one, press :\n"

        self.addActions(self.actionsList)
        for a in self.actionsList:
            self.text += "  - " + a.shortcut.toString() + " to " + a.text + ".\n"

        box.addWidget(QLabel(self.text, self))
        fBox = QFormLayout()
        self.handleLabel = QLabel("None selected", self)
        fBox.addRow("Current handle", self.handleLabel)
        self.gripperLabel = QLabel("None selected", self)
        fBox.addRow("Current gripper", self.gripperLabel)
        box.addLayout(fBox)

        self.mainWindow.connect("selectJointFromBodyName(QString)", self.changeSelected)
コード例 #7
0
    def initgui(self):
        #qt widget ui
        group = QGroupBox()
        box = QVBoxLayout(group)

        self.openbut = QPushButton("init", group)
        self.lockbut = QPushButton("init", group)
        box.addWidget(self.openbut)
        box.addWidget(self.lockbut)

        self.openbut.connect('clicked()', self.open)
        self.lockbut.connect('clicked()', self.lock)

        self.widget = group
        self.forcepos = None

        #naali proxywidget boilerplate
        uism = naali.ui
        self.proxywidget = r.createUiProxyWidget(self.widget)
        self.proxywidget.setWindowTitle(self.GUINAME)
        if not uism.AddWidgetToScene(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."
コード例 #8
0
ファイル: door.py プロジェクト: A-K/naali
    def initgui(self):
        #qt widget ui
        group = QGroupBox()
        box = QVBoxLayout(group)

        self.openbut = QPushButton("init", group)
        self.lockbut = QPushButton("init", group)
        box.addWidget(self.openbut)
        box.addWidget(self.lockbut)

        self.openbut.connect('clicked()', self.open)
        self.lockbut.connect('clicked()', self.lock)

        self.widget = group
        self.forcepos = None

        #naali proxywidget boilerplate
        uism = naali.ui
        self.proxywidget = r.createUiProxyWidget(self.widget)
        self.proxywidget.setWindowTitle(self.GUINAME)
        if not uism.AddWidgetToScene(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."
コード例 #9
0
    def __init__(self):
        Component.__init__(self)
        #loader = QUiLoader()
        #uism = r.getUiSceneManager() #self.canvas = r.createCanvas(EXTERNAL)

        group = QGroupBox()
        box = QVBoxLayout(group)

        button1 = QPushButton("Button 1", group)
        box.addWidget(button1)

        button2 = QPushButton("Button 2", group)
        box.addWidget(button2)

        slider = QtGui.QSlider(PythonQt.QtCore.Qt.Horizontal)
        box.addWidget(slider)
        slider.connect('valueChanged(int)', self.changed)

        #group.show()

        lineedit = QtGui.QLineEdit()
        box.addWidget(lineedit)
        lineedit.connect('textChanged(QString)', self.changed)

        self.widget = group

        #naali proxywidget boilerplate
        GUINAME = "Python Webmodule Test"
        uism = naali.ui
        self.proxywidget = r.createUiProxyWidget(self.widget)
        self.proxywidget.setWindowTitle(GUINAME)
        if not uism.AddWidgetToScene(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."
        # TODO: Due to core UI API refactor AddWidgetToMenu doesn't exist anymore.
        #uism.AddWidgetToMenu(self.proxywidget, GUINAME, "Developer Tools")

        #self.canvas.Show()

        #QInputDialog.getText(None, "Mesh asset UUID", "Please give mesh asset UUID", QLineEdit.Normal, "")

        r.logInfo("TestGui inited.")
コード例 #10
0
ファイル: webmodule_example.py プロジェクト: A-K/naali
    def __init__(self):
        Component.__init__(self)
        #loader = QUiLoader()
        #uism = r.getUiSceneManager() #self.canvas = r.createCanvas(EXTERNAL)

        group = QGroupBox()
        box = QVBoxLayout(group)

        button1 = QPushButton("Button 1", group)
        box.addWidget(button1)

        button2 = QPushButton("Button 2", group)
        box.addWidget(button2)

        slider = QtGui.QSlider(PythonQt.QtCore.Qt.Horizontal)
        box.addWidget(slider)
        slider.connect('valueChanged(int)', self.changed)

        #group.show()

        lineedit = QtGui.QLineEdit()
        box.addWidget(lineedit)
        lineedit.connect('textChanged(QString)', self.changed)

        self.widget = group

        #naali proxywidget boilerplate
        GUINAME = "Python Webmodule Test"
        uism = naali.ui
        self.proxywidget = r.createUiProxyWidget(self.widget)
        self.proxywidget.setWindowTitle(GUINAME)
        if not uism.AddWidgetToScene(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."
        # TODO: Due to core UI API refactor AddWidgetToMenu doesn't exist anymore.
        #uism.AddWidgetToMenu(self.proxywidget, GUINAME, "Developer Tools")

        #self.canvas.Show()

        #QInputDialog.getText(None, "Mesh asset UUID", "Please give mesh asset UUID", QLineEdit.Normal, "")

        r.logInfo("TestGui inited.")
コード例 #11
0
ファイル: pythonqt_gui.py プロジェクト: Chiru/naali
    def __init__(self):
        Component.__init__(self)
        #loader = QUiLoader()
        #uism = r.getUiSceneManager() #self.canvas = r.createCanvas(EXTERNAL)

        group = QGroupBox()
        box = QVBoxLayout(group)

        button1 = QPushButton("Button 1", group)
        box.addWidget(button1)

        button2 = QPushButton("Button 2", group)
        box.addWidget(button2)

        slider = QtGui.QSlider(PythonQt.QtCore.Qt.Horizontal)
        box.addWidget(slider)
        slider.connect('valueChanged(int)', self.changed)

        #group.show()

        lineedit = QtGui.QLineEdit()
        box.addWidget(lineedit)
        lineedit.connect('textChanged(QString)', self.changed)

        self.widget = group

        uism = r.getUiSceneManager()
        uiprops = r.createUiWidgetProperty(1)
        uiprops.widget_name_ = "Test Widget"
        #uiprops.my_size_ = QSize(width, height)
        #self.proxywidget = uism.AddWidgetToScene(ui, uiprops)
        self.proxywidget = r.createUiProxyWidget(self.widget, uiprops)
        ##print widget, dir(widget)
        if not uism.AddProxyWidget(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."

        #self.canvas.Show()

        #QInputDialog.getText(None, "Mesh asset UUID", "Please give mesh asset UUID", QLineEdit.Normal, "")

        r.logInfo("TestGui inited.")
コード例 #12
0
ファイル: pythonqt_gui.py プロジェクト: marijamarkovic/naali
    def __init__(self):
        Component.__init__(self)
        #loader = QUiLoader()
        #uism = r.getUiSceneManager() #self.canvas = r.createCanvas(EXTERNAL)

        group = QGroupBox()
        box = QVBoxLayout(group)

        button1 = QPushButton("Button 1", group)
        box.addWidget(button1)

        button2 = QPushButton("Button 2", group)
        box.addWidget(button2)

        slider = QtGui.QSlider(PythonQt.QtCore.Qt.Horizontal)
        box.addWidget(slider)
        slider.connect('valueChanged(int)', self.changed)

        #group.show()

        lineedit = QtGui.QLineEdit()
        box.addWidget(lineedit)
        lineedit.connect('textChanged(QString)', self.changed)

        self.widget = group

        uism = r.getUiSceneManager()
        uiprops = r.createUiWidgetProperty(1)
        uiprops.widget_name_ = "Test Widget"
        #uiprops.my_size_ = QSize(width, height)
        #self.proxywidget = uism.AddWidgetToScene(ui, uiprops)
        self.proxywidget = r.createUiProxyWidget(self.widget, uiprops)
        ##print widget, dir(widget)
        if not uism.AddProxyWidget(self.proxywidget):
            print "Adding the ProxyWidget to the bar failed."

        #self.canvas.Show()

        #QInputDialog.getText(None, "Mesh asset UUID", "Please give mesh asset UUID", QLineEdit.Normal, "")

        r.logInfo("TestGui inited.")
コード例 #13
0
ファイル: window.py プロジェクト: A-K/naali
    def __init__(self, controller):
        self.controller = controller
        loader = QUiLoader()
        loader.setLanguageChangeEnabled(True)
        uifile = QFile(self.UIFILE)

        ui = loader.load(uifile)
        width = ui.size.width()
        height = ui.size.height()
        
        uism = naali.ui

        self.widget = ui

        # Material/Texture widgets
        self.materialTabFormWidget = ui.findChild("QWidget", "MaterialsTab").formLayoutWidget

        # Mesh line edit and buttons
        self.meshline = lines.MeshAssetidEditline(controller) 
        self.meshline.name = "meshLineEdit"

        button_ok = self.getButton("Apply", self.ICON_OK, self.meshline, self.meshline.applyAction)
        button_cancel = self.getButton("Cancel", self.ICON_CANCEL, self.meshline, self.meshline.cancelAction)
        button_browse = self.getButton("Browse", self.ICON_FOLDER, None, None)
        
        box = QHBoxLayout()
        box.setContentsMargins(0,0,0,0)
        box.addWidget(self.meshline)
        box.addWidget(button_browse)
        box.addWidget(button_ok)
        box.addWidget(button_cancel)
        self.mesh_widget = QWidget()
        self.mesh_widget.setLayout(box)
        
        # Sound line edit and buttons
        self.soundline = lines.SoundAssetidEditline(controller) 
        self.soundline.name = "soundLineEdit"
        soundbutton_ok = self.getButton("Apply", self.ICON_OK, self.soundline, self.soundline.applyAction)
        soundbutton_cancel = self.getButton("Cancel", self.ICON_CANCEL, self.soundline, self.soundline.cancelAction)
        soundbutton_browse = self.getButton("Browse", self.ICON_FOLDER, None, None)
        soundRadius = self.getDoubleSpinBox("soundRadius", "Set sound radius", self.soundline)
        soundVolume = self.getDoubleSpinBox("soundVolume", "Set sound volume", self.soundline)
        
        main_box = QVBoxLayout()
        main_box.setContentsMargins(0,0,0,0)
        box_buttons = QHBoxLayout()
        box_buttons.setContentsMargins(0,0,0,0)
        
        # TODO no need for self?
        # crashed always if didnt put self to second label :P you can try to remove them...
        # basically the qwidget ptr must stay somewhere in py otherwise will crash when gets to painting -Pforce
        self.label_radius = QLabel("Radius")
        self.label_radius.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        self.label_volume = QLabel("Volume")
        self.label_volume.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)

        box_buttons.addWidget(self.label_radius)
        box_buttons.addWidget(soundRadius)
        box_buttons.addWidget(self.label_volume)
        box_buttons.addWidget(soundVolume)
        box_buttons.addWidget(soundbutton_browse)        
        box_buttons.addWidget(soundbutton_ok)
        box_buttons.addWidget(soundbutton_cancel)

        main_box.addWidget(self.soundline)
        main_box.addLayout(box_buttons)
        self.sound_widget = QWidget()
        self.sound_widget.setLayout(main_box)

        # Animation line edit and buttons
        self.animation_title = QLabel("Skeleton Animation")
        self.animation_title.setStyleSheet("font-size:18px;font-weight:bold;padding-top:5px;")
        self.animation_title.setIndent(0)
        self.animationline = lines.AnimationAssetidEditline(controller)
        self.animationline.name = "animationLineEdit"
        animation_combobox = self.getCombobox("AnimationName", "Animation Name", self.animationline)
        animationbutton_ok = self.getButton("Apply", self.ICON_OK, self.animationline, self.animationline.applyAction)
        animationbutton_cancel = self.getButton("Cancel", self.ICON_CANCEL, self.animationline, self.animationline.cancelAction)
        animationbutton_browse = self.getButton("Browse", self.ICON_FOLDER, None, None)
        animationRate = self.getDoubleSpinBox("animationRate", "Set animation rate", self.animationline)

        animationbox = QVBoxLayout()
        animationbox.setContentsMargins(0,0,0,0)
        self.anim_box_buttons = QHBoxLayout()
        self.anim_box_buttons.name = "AnimBoxButtons"
        self.anim_box_buttons.setContentsMargins(0,0,0,0)

        label_rate = QLabel("Rate")
        label_rate.name = "Animation Rate"
        label_rate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)

        self.anim_box_buttons.addWidget(animation_combobox)
        self.anim_box_buttons.addWidget(label_rate)
        self.anim_box_buttons.addWidget(animationRate)
        self.anim_box_buttons.addWidget(animationbutton_browse)
        self.anim_box_buttons.addWidget(animationbutton_ok)
        self.anim_box_buttons.addWidget(animationbutton_cancel)

        animationbox.addWidget(self.animation_title)
        animationbox.addWidget(self.animationline)
        animationbox.addLayout(self.anim_box_buttons)
        self.animation_widget = QWidget()
        self.animation_widget.setLayout(animationbox)
        self.animation_widget.hide()

        self.updatingSelection = False
        
        # mesh buttons
        self.meshline.connect('textEdited(QString)', button_ok.lineValueChanged)
        self.meshline.connect('textEdited(QString)', button_cancel.lineValueChanged)

        # audio buttons
        self.soundline.connect('textEdited(QString)', soundbutton_ok.lineValueChanged)
        self.soundline.connect('textEdited(QString)', soundbutton_cancel.lineValueChanged)
        soundRadius.connect('valueChanged(double)', soundbutton_ok.lineValueChanged)
        soundRadius.connect('valueChanged(double)', soundbutton_cancel.lineValueChanged)
        soundVolume.connect('valueChanged(double)', soundbutton_ok.lineValueChanged)
        soundVolume.connect('valueChanged(double)', soundbutton_cancel.lineValueChanged)

        # animation buttons
        self.animationline.connect('textEdited(QString)', animationbutton_ok.lineValueChanged)
        self.animationline.connect('textEdited(QString)', animationbutton_cancel.lineValueChanged)
        animationRate.connect('valueChanged(double)', animationbutton_ok.lineValueChanged)
        animationRate.connect('valueChanged(double)', animationbutton_cancel.lineValueChanged)
        animation_combobox.connect('currentIndexChanged(int)', animationbutton_ok.lineValueChanged)
        animation_combobox.connect('currentIndexChanged(int)', animationbutton_cancel.lineValueChanged)

        self.mainTabList = {}
        self.currentlySelectedTreeWidgetItem = []
コード例 #14
0
class EventlogDialog(QDialog):
    def __init__(self, cfg, parent):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle("Eventlog")

        self.cfg = cfg

        self.pauseButton = QPushButton("Pause", self)
        self.pauseButton.setCheckable(True)
        self.pauseButton.connect("toggled(bool)", self.onPauseButtonToggled)
        self.spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.maxLabel = QLabel("Maximum Events:", self)
        self.maxSpin = QSpinBox(self)
        self.maxSpin.setMaximum(10000)
        self.maxSpin.setToolTip("Set to 0 to not shrink events at all")
        self.maxSpin.setValue(cfg.getint("maximumEvents"))
        self.maxSpin.connect("valueChanged(int)", self.onMaxSpinChanged)

        self.sublay1 = QHBoxLayout()
        self.sublay1.addWidget(self.pauseButton)
        self.sublay1.addItem(self.spacer)
        self.sublay1.addWidget(self.maxLabel)
        self.sublay1.addWidget(self.maxSpin)

        self.filterLabel = QLabel("Filter:", self)
        self.filterEdit = QLineEdit(self)
        self.filterEdit.connect("textChanged(QString)",
                                self.onFilterEditChanged)
        self.filterButton = QToolButton(self)
        self.filterButton.connect("clicked()", self.filterEdit.clear)
        try:
            ico = ts3client.IconPack.current()
            ico.open()
            self.filterButton.setIcon(QIcon(ico.icon("ERROR")))
            ico.close()
        except Exception as e:
            self.filterButton.setText("X")

        self.sublay2 = QHBoxLayout()
        self.sublay2.addWidget(self.filterLabel)
        self.sublay2.addWidget(self.filterEdit)
        self.sublay2.addWidget(self.filterButton)

        self.model = EventlogModel(self)
        self.model.maximumEvents = cfg.getint("maximumEvents")
        self.proxy = QSortFilterProxyModel(self)
        self.proxy.setFilterRole(Qt.UserRole)
        self.proxy.setSourceModel(self.model)

        self.tree = QTreeView(self)
        self.tree.header().hide()
        self.tree.setModel(self.proxy)

        self.lay = QVBoxLayout(self)
        self.lay.addLayout(self.sublay1)
        self.lay.addLayout(self.sublay2)
        self.lay.addWidget(self.tree)

        self.resize(cfg.getint("width"), cfg.getint("height"))

        self.connect("finished(int)", self.onFinished)

    def onMaxSpinChanged(self, val):
        self.model.maximumEvents = val
        self.cfg["maximumEvents"] = str(val)

    def onFilterEditChanged(self, txt):
        self.proxy.setFilterRegExp(txt)

    def onPauseButtonToggled(self, checked):
        if checked:
            self.model.pause()
        else:
            self.model.unpause()

    def onFinished(self, result):
        self.cfg["width"] = str(self.width)
        self.cfg["height"] = str(self.height)

    def callback(self, name, *args):
        self.model.callback(name, *args)
コード例 #15
0
ファイル: graphutility.py プロジェクト: lineCode/hpp-gui
    def initWidget(self):
        # Main layout
        mainBox = QVBoxLayout(self)

        # Add text edit to write regex by hand
        box = QVBoxLayout()
        mainBox.addLayout(box)
        self.textEdit = QLineEdit(self)
        box.addWidget(QLabel("You can write your regexp here", self))
        box.addWidget(self.textEdit)
        button = QPushButton("Find", self)
        button.connect("clicked()", self.applyRegex)
        box.addWidget(button)

        # Add grippers list
        self.grippersList = QListWidget(self)
        mainBox.addWidget(self.grippersList)

        # Sub layout for the action type
        box = QHBoxLayout()
        mainBox.addLayout(box)
        self.graspCheck = QCheckBox("Grasp", self)
        box.addWidget(self.graspCheck)
        self.pregraspCheck = QCheckBox("Pregrasp", self)
        box.addWidget(self.pregraspCheck)

        # Add handle list
        self.handlesList = QListWidget(self)
        mainBox.addWidget(self.handlesList)

        # Add a table to display results
        self.resultList = QListWidget(self)
        mainBox.addWidget(self.resultList)

        # Add button to refresh
        button = QPushButton(self)
        button.setText("Refresh")
        button.connect("clicked()", self.refresh)
        mainBox.addWidget(button)

        # Get the grippers and handles names
        # Connect the widget to functions
        self.addConnection()
コード例 #16
0
class InfoDialog(QDialog):
    def __init__(self):
        super(QDialog, self).__init__(None)
        
        self.setAttribute(Qt.WA_DeleteOnClose)
        
        self.splitter = QSplitter(Qt.Horizontal, self)
        self.leftwidg = QWidget(self)
        self.vlayout = QVBoxLayout(self.leftwidg)
        self.checkbox = QCheckBox("Mark selection", self)
        self.tree = QTreeView(self)
        self.tree.header().hide()
        self.vlayout.addWidget(self.checkbox)
        self.vlayout.addWidget(self.tree)
        self.table = QTableView(self)
        self.table.horizontalHeader().setStretchLastSection(True)
        
        self.splitter.addWidget(self.leftwidg)
        self.splitter.addWidget(self.table)
        
        self.hlayout = QHBoxLayout(self)
        self.hlayout.addWidget(self.splitter)   
        
        self.treemodel = WidgetModel(self.tree)
        self.tree.setModel(self.treemodel)
        
        self.tablemodel = PropertyModel(self.table)
        self.table.setModel(self.tablemodel)
        
        self.stylesheet = None

        self.connect("finished(int)", self.onClosed)
        self.tree.selectionModel().connect("currentChanged(const QModelIndex&, const QModelIndex&)", self.onTreeSelectionChanged)
        self.tree.connect("doubleClicked(const QModelIndex&)", self.onTreeDoubleClicked)
        self.checkbox.connect("toggled(bool)", self.onCheckBoxClicked)
        
        self.resize(800, 500)
        
    def onClosed(self):
        if self.checkbox.isChecked() and self.stylesheet is not None:
            index = self.tree.selectionModel().currentIndex
            if index.isValid():
                obj = index.internalPointer() 
                if hasattr(obj, "setStyleSheet"):
                    obj.setStyleSheet(self.stylesheet)
    
        
    def setWidget(self, widg):
        self.widget = widg
        
        tlw = QApplication.topLevelWidgets()
        
        if widg in tlw:
            index = self.treemodel.createIndex(tlw.index(widg), 0, widg)
        else:
            index = self.treemodel.createIndex(widg.parent().children().index(widg), 0, widg)
            
        self.tree.selectionModel().select(index, QItemSelectionModel.ClearAndSelect)
        self.tree.scrollTo(index)
        
        while index.isValid():
            self.tree.expand(index)
            index = index.parent()
        
        self.tablemodel.setWidget(widg)
        
    def onTreeDoubleClicked(self, index):
        obj = index.internalPointer()
        
        if obj.inherits("QMenu"):
            obj.popup(QCursor.pos())

        
    def onTreeSelectionChanged(self, cur, prev):
        obj = cur.internalPointer()
    
        self.tablemodel.setWidget(obj)
    
        if self.checkbox.isChecked():
            if prev.isValid() and self.stylesheet is not None:
                oldobj = prev.internalPointer()
                if hasattr(oldobj, "setStyleSheet"):
                    oldobj.setStyleSheet(self.stylesheet)
    
            if hasattr(obj, "setStyleSheet"):
                self.stylesheet = obj.styleSheet
                obj.setStyleSheet("background: red;")    
        
    def onCheckBoxClicked(self, act):
        index = self.tree.selectionModel().currentIndex
        if not index.isValid():
            return
            
        obj = index.internalPointer()
        if not hasattr(obj, "setStyleSheet"):
            return
            
        if act:
            self.stylesheet = obj.styleSheet
            obj.setStyleSheet("background: red;")
        elif self.stylesheet is not None:
            obj.setStyleSheet(self.stylesheet)
コード例 #17
0
ファイル: window.py プロジェクト: etradewind/Tundra2
    def __init__(self, controller):
        self.controller = controller
        loader = QUiLoader()
        loader.setLanguageChangeEnabled(True)
        uifile = QFile(self.UIFILE)

        ui = loader.load(uifile)
        width = ui.size.width()
        height = ui.size.height()

        uism = naali.ui

        self.widget = ui

        # Material/Texture widgets
        self.materialTabFormWidget = ui.findChild(
            "QWidget", "MaterialsTab").formLayoutWidget

        # Mesh line edit and buttons
        self.meshline = lines.MeshAssetidEditline(controller)
        self.meshline.name = "meshLineEdit"

        button_ok = self.getButton("Apply", self.ICON_OK, self.meshline,
                                   self.meshline.applyAction)
        button_cancel = self.getButton("Cancel", self.ICON_CANCEL,
                                       self.meshline,
                                       self.meshline.cancelAction)
        button_browse = self.getButton("Browse", self.ICON_FOLDER, None, None)

        box = QHBoxLayout()
        box.setContentsMargins(0, 0, 0, 0)
        box.addWidget(self.meshline)
        box.addWidget(button_browse)
        box.addWidget(button_ok)
        box.addWidget(button_cancel)
        self.mesh_widget = QWidget()
        self.mesh_widget.setLayout(box)

        # Sound line edit and buttons
        self.soundline = lines.SoundAssetidEditline(controller)
        self.soundline.name = "soundLineEdit"
        soundbutton_ok = self.getButton("Apply", self.ICON_OK, self.soundline,
                                        self.soundline.applyAction)
        soundbutton_cancel = self.getButton("Cancel", self.ICON_CANCEL,
                                            self.soundline,
                                            self.soundline.cancelAction)
        soundbutton_browse = self.getButton("Browse", self.ICON_FOLDER, None,
                                            None)
        soundRadius = self.getDoubleSpinBox("soundRadius", "Set sound radius",
                                            self.soundline)
        soundVolume = self.getDoubleSpinBox("soundVolume", "Set sound volume",
                                            self.soundline)

        main_box = QVBoxLayout()
        main_box.setContentsMargins(0, 0, 0, 0)
        box_buttons = QHBoxLayout()
        box_buttons.setContentsMargins(0, 0, 0, 0)

        # TODO no need for self?
        # crashed always if didnt put self to second label :P you can try to remove them...
        # basically the qwidget ptr must stay somewhere in py otherwise will crash when gets to painting -Pforce
        self.label_radius = QLabel("Radius")
        self.label_radius.setSizePolicy(QSizePolicy.Fixed,
                                        QSizePolicy.Preferred)
        self.label_volume = QLabel("Volume")
        self.label_volume.setSizePolicy(QSizePolicy.Fixed,
                                        QSizePolicy.Preferred)

        box_buttons.addWidget(self.label_radius)
        box_buttons.addWidget(soundRadius)
        box_buttons.addWidget(self.label_volume)
        box_buttons.addWidget(soundVolume)
        box_buttons.addWidget(soundbutton_browse)
        box_buttons.addWidget(soundbutton_ok)
        box_buttons.addWidget(soundbutton_cancel)

        main_box.addWidget(self.soundline)
        main_box.addLayout(box_buttons)
        self.sound_widget = QWidget()
        self.sound_widget.setLayout(main_box)

        # Animation line edit and buttons
        self.animation_title = QLabel("Skeleton Animation")
        self.animation_title.setStyleSheet(
            "font-size:18px;font-weight:bold;padding-top:5px;")
        self.animation_title.setIndent(0)
        self.animationline = lines.AnimationAssetidEditline(controller)
        self.animationline.name = "animationLineEdit"
        animation_combobox = self.getCombobox("AnimationName",
                                              "Animation Name",
                                              self.animationline)
        animationbutton_ok = self.getButton("Apply", self.ICON_OK,
                                            self.animationline,
                                            self.animationline.applyAction)
        animationbutton_cancel = self.getButton(
            "Cancel", self.ICON_CANCEL, self.animationline,
            self.animationline.cancelAction)
        animationbutton_browse = self.getButton("Browse", self.ICON_FOLDER,
                                                None, None)
        animationRate = self.getDoubleSpinBox("animationRate",
                                              "Set animation rate",
                                              self.animationline)

        animationbox = QVBoxLayout()
        animationbox.setContentsMargins(0, 0, 0, 0)
        self.anim_box_buttons = QHBoxLayout()
        self.anim_box_buttons.name = "AnimBoxButtons"
        self.anim_box_buttons.setContentsMargins(0, 0, 0, 0)

        label_rate = QLabel("Rate")
        label_rate.name = "Animation Rate"
        label_rate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)

        self.anim_box_buttons.addWidget(animation_combobox)
        self.anim_box_buttons.addWidget(label_rate)
        self.anim_box_buttons.addWidget(animationRate)
        self.anim_box_buttons.addWidget(animationbutton_browse)
        self.anim_box_buttons.addWidget(animationbutton_ok)
        self.anim_box_buttons.addWidget(animationbutton_cancel)

        animationbox.addWidget(self.animation_title)
        animationbox.addWidget(self.animationline)
        animationbox.addLayout(self.anim_box_buttons)
        self.animation_widget = QWidget()
        self.animation_widget.setLayout(animationbox)
        self.animation_widget.hide()

        self.updatingSelection = False

        # mesh buttons
        self.meshline.connect('textEdited(QString)',
                              button_ok.lineValueChanged)
        self.meshline.connect('textEdited(QString)',
                              button_cancel.lineValueChanged)

        # audio buttons
        self.soundline.connect('textEdited(QString)',
                               soundbutton_ok.lineValueChanged)
        self.soundline.connect('textEdited(QString)',
                               soundbutton_cancel.lineValueChanged)
        soundRadius.connect('valueChanged(double)',
                            soundbutton_ok.lineValueChanged)
        soundRadius.connect('valueChanged(double)',
                            soundbutton_cancel.lineValueChanged)
        soundVolume.connect('valueChanged(double)',
                            soundbutton_ok.lineValueChanged)
        soundVolume.connect('valueChanged(double)',
                            soundbutton_cancel.lineValueChanged)

        # animation buttons
        self.animationline.connect('textEdited(QString)',
                                   animationbutton_ok.lineValueChanged)
        self.animationline.connect('textEdited(QString)',
                                   animationbutton_cancel.lineValueChanged)
        animationRate.connect('valueChanged(double)',
                              animationbutton_ok.lineValueChanged)
        animationRate.connect('valueChanged(double)',
                              animationbutton_cancel.lineValueChanged)
        animation_combobox.connect('currentIndexChanged(int)',
                                   animationbutton_ok.lineValueChanged)
        animation_combobox.connect('currentIndexChanged(int)',
                                   animationbutton_cancel.lineValueChanged)

        self.mainTabList = {}
        self.currentlySelectedTreeWidgetItem = []