Beispiel #1
0
    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()
    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.")
Beispiel #3
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

        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.")
Beispiel #4
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."
Beispiel #5
0
Datei: door.py Projekt: 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."
Beispiel #6
0
class DoorHandler(circuits.BaseComponent):
    GUINAME = "Door Handler"
    ADDMENU = True

    def __init__(self, entity, comp, changetype):
        self.comp = comp
        circuits.BaseComponent.__init__(self)

        comp.connect("OnChanged()", self.onChanged)
        self.inworld_inited = False  #a cheap hackish substitute for some initing system
        self.initgui()

    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 = r.getUiSceneManager()
        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."
        uism.AddWidgetToMenu(self.proxywidget, self.GUINAME, "Developer Tools")

    def onChanged(self):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError:  #the entity has been removed or something
            return

        print "door data changed"

        if not self.inworld_inited:
            #if hasattr(self.comp, 'touchable')
            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in door? it doesn't persist yet? adding..", ent.id
                ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in door."
            t.connect('Clicked()', self.open)
            t.connect('MouseHoverIn()', self.hover_in)
            t.connect('MouseHoverOut()', self.hover_out)
            self.inworld_inited = True

        opened = self.opened
        locked = self.locked

        newpos = OPENPOS if opened else CLOSEPOS
        ent.placeable.Position = newpos
        #print opened, type(opened), ent.placeable.Position

        self.openbut.text = "Close" if opened else "Open"
        self.lockbut.text = "Unlock" if locked else "Lock"
        if locked and not opened:
            self.openbut.enabled = False
        else:
            self.openbut.enabled = True
        """NOTE:
        this code doesn't now sync the normal ob pos to server
        at all. the object is moved in all clients only.
        when logging back to a server, wasn't seeing the right positions,
        probably because server send pos update after the comp sync."""
        self.forcepos = ent.placeable.Position

    def get_opened(self):
        if self.comp is not None:
            return self.comp.GetAttribute("opened")
        else:
            return None

    def set_opened(self, newval):
        self.comp.SetAttribute("opened", newval)
        self.comp.OnChanged()

    opened = property(get_opened, set_opened)

    def get_locked(self):
        if self.comp is not None:
            return self.comp.GetAttribute("locked")
        else:
            return None

    def set_locked(self, newval):
        self.comp.SetAttribute("locked", newval)
        self.comp.OnChanged()

    locked = property(get_locked, set_locked)

    def open(self):
        #print "open"
        if self.opened or not self.locked:
            self.opened = not self.opened
            print self.opened
        else:
            print "Can't open a locked door!"

    def lock(self):
        #\todo if has key
        self.locked = not self.locked

    def hover_in(self):
        #XXX add locked check too
        ctype = 1 if self.opened else 2
        setcursor(ctype)

    def hover_out(self):
        curr_cursor = qapp.overrideCursor()
        while curr_cursor != None:
            qapp.restoreOverrideCursor()
            curr_cursor = qapp.overrideCursor()

    @circuits.handler("update")
    def update(self, t):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError:  #the entity has been removed or something
            return  # nothing useful to do anyway

        if self.forcepos is not None:
            ent.placeable.Position = self.forcepos

    @circuits.handler("on_logout")
    def removegui(self, evid):
        self.proxywidget.hide()
        uism = r.getUiSceneManager()
        uism.RemoveWidgetFromMenu(self.proxywidget)
        uism.RemoveWidgetFromScene(self.proxywidget)
Beispiel #7
0
    rect_a = PythonQt.QtCore.QRect(point_a_tl, point_a_br)
    print "Rect A: ", rect_a.toString()
    rect_b = PythonQt.QtCore.QRect(point_b_tl, point_b_br)
    print "Rect B: ", rect_b.toString()
    print "intersects: ", rect_a.intersects(rect_b)
    
    rect_c = rect_a.intersected(rect_b)
    print "intersected:", rect_c.toString()

if 0:
    from PythonQt.QtGui import *

    group = QGroupBox()
    box = QVBoxLayout(group)
    print dir(box)
    push1 =  QPushButton(group)
    box.addWidget(push1)
    push2 =  QPushButton(group)
    box.addWidget(push2)
    check =  QCheckBox(group)
    check.text = 'check me'
    group.title = 'my title'
    push1.text = 'press me'
    push2.text = 'press me2'
    box.addWidget(check)
    group.show()

if 0:
    box = r.c.widget
    def funk(item):
        print "got index...", item
Beispiel #8
0
 def __init__(self, *args):
     QPushButton.__init__(self, args)
Beispiel #9
0
    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)
Beispiel #10
0
    rect_a = PythonQt.QtCore.QRect(point_a_tl, point_a_br)
    print "Rect A: ", rect_a.toString()
    rect_b = PythonQt.QtCore.QRect(point_b_tl, point_b_br)
    print "Rect B: ", rect_b.toString()
    print "intersects: ", rect_a.intersects(rect_b)

    rect_c = rect_a.intersected(rect_b)
    print "intersected:", rect_c.toString()

if 0:
    from PythonQt.QtGui import *

    group = QGroupBox()
    box = QVBoxLayout(group)
    print dir(box)
    push1 = QPushButton(group)
    box.addWidget(push1)
    push2 = QPushButton(group)
    box.addWidget(push2)
    check = QCheckBox(group)
    check.text = 'check me'
    group.title = 'my title'
    push1.text = 'press me'
    push2.text = 'press me2'
    box.addWidget(check)
    group.show()

if 0:
    box = r.c.widget

    def funk(item):
Beispiel #11
0
class DoorHandler(circuits.BaseComponent):
    GUINAME = "Door Handler"
    ADDMENU = True

    def __init__(self, entity, comp, changetype):
        self.comp = comp
        circuits.BaseComponent.__init__(self)

        comp.connect("OnChanged()", self.onChanged)
        self.inworld_inited = False #a cheap hackish substitute for some initing system
        self.initgui()

    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 = r.getUiSceneManager()
        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."
        uism.AddWidgetToMenu(self.proxywidget, self.GUINAME, "Developer Tools")

    def onChanged(self):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError: #the entity has been removed or something
            return

        print "door data changed"

        if not self.inworld_inited:
            #if hasattr(self.comp, 'touchable')
            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in door? it doesn't persist yet? adding..", ent.id
                ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in door."
            t.connect('Clicked()', self.open)
            t.connect('MouseHoverIn()', self.hover_in)
            t.connect('MouseHoverOut()', self.hover_out)
            self.inworld_inited = True

        opened = self.opened
        locked = self.locked

        newpos = OPENPOS if opened else CLOSEPOS
        ent.placeable.Position = newpos        
        #print opened, type(opened), ent.placeable.Position

        self.openbut.text = "Close" if opened else "Open"
        self.lockbut.text = "Unlock" if locked else "Lock"
        if locked and not opened:
            self.openbut.enabled = False
        else:
            self.openbut.enabled = True
        
        """NOTE:
        this code doesn't now sync the normal ob pos to server
        at all. the object is moved in all clients only.
        when logging back to a server, wasn't seeing the right positions,
        probably because server send pos update after the comp sync."""
        self.forcepos = ent.placeable.Position
        
    def get_opened(self):
        if self.comp is not None:
            return self.comp.GetAttribute("opened")
        else:
            return None
    def set_opened(self, newval):
        self.comp.SetAttribute("opened", newval)
        self.comp.OnChanged()
    opened = property(get_opened, set_opened)

    def get_locked(self):
        if self.comp is not None:
            return self.comp.GetAttribute("locked")
        else:
            return None
    def set_locked(self, newval):
        self.comp.SetAttribute("locked", newval)
        self.comp.OnChanged()
    locked = property(get_locked, set_locked)

    def open(self):
        #print "open"
        if self.opened or not self.locked:
            self.opened = not self.opened
            print self.opened
        else:
            print "Can't open a locked door!"

    def lock(self):
        #\todo if has key
        self.locked = not self.locked

    def hover_in(self):
        #XXX add locked check too
        ctype = 1 if self.opened else 2
        setcursor(ctype)

    def hover_out(self):
        curr_cursor = qapp.overrideCursor()
        while curr_cursor != None:
            qapp.restoreOverrideCursor()
            curr_cursor = qapp.overrideCursor()

    @circuits.handler("update")
    def update(self, t):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError: #the entity has been removed or something
            return # nothing useful to do anyway

        if self.forcepos is not None:
                ent.placeable.Position = self.forcepos

    @circuits.handler("on_logout")
    def removegui(self, evid):
        self.proxywidget.hide()
        uism = r.getUiSceneManager()
        uism.RemoveWidgetFromMenu(self.proxywidget)
        uism.RemoveWidgetFromScene(self.proxywidget)
Beispiel #12
0
 def __init__(self, *args):
     QPushButton.__init__(self, args)