def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, meta = ts3.getClientVariableAsString(schid, ownid, ClientProperties.CLIENT_META_DATA) if error == ERROR_ok: x = QWidget() _meta = QInputDialog.getMultiLineText(x, "Change own Meta Data", "Meta Data:", meta) if _meta == meta: return error = ts3.setClientSelfVariableAsString(schid, ClientProperties.CLIENT_META_DATA, _meta) if not error == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error, "Unable to set own meta data!");_t.show() elif menuItemID == 1: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, flag = ts3.getClientVariableAsString(schid, ownid, ClientPropertiesRare.CLIENT_FLAG_AVATAR) ts3.printMessageToCurrentTab("Your current avatar flag is: %s"%flag) if error == ERROR_ok: x = QWidget() _flag = QInputDialog.getText(x, "Change own Avatar Flag", "Avatar File MD5:") if _flag == "x" or _flag.strip() == flag.strip(): return error = ts3.setClientSelfVariableAsString(schid, ClientPropertiesRare.CLIENT_FLAG_AVATAR, _flag) error2 = ts3.flushClientSelfUpdates(schid) if not error == ERROR_ok or not error2 == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own avatar flag!");_t.show()
def confirm(title, message): """ :param title: :param message: :return: """ x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: return True if _x == QMessageBox.Yes else False
def inputBox(parent, title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QWidget(parent) x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) if ok: return text else: return False
def inputBox(title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() if not default: default = QApplication.clipboard().text() text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) # QDir.Home.dirName() if ok: return text else: return False
def onMenuItemEvent(self, schid, atype, menuItemID, channel): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0: try: x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) password = QInputDialog.getText(x, "Enter Channel Password", "Password:"******"clients: {0}".format(clients)) (error, maxclients) = ts3lib.getChannelVariableAsUInt64( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxclients: {1}".format( error, maxclients)) (error, maxfamilyclients) = ts3lib.getChannelVariableAsUInt64( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxfamilyclients: {1}".format( error, maxfamilyclients)) if clients < maxclients and clients < maxfamilyclients: (error, ownID) = ts3lib.getClientID(schid) ts3lib.requestClientMove(schid, ownID, channel, password) return True (error, name) = ts3lib.getChannelVariableAsString( schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME) self.schid = schid self.channel = channel self.password = password self.cname = name if password == "": ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining." .format(channel, name, maxclients - clients + 1)) else: ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining." .format(channel, name, password, maxclients - clients + 1)) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def inputInt(title="", label="", val=0, min=-2147483647, max=2147483647, step=1): """ :param title: :param label: :param val: :param min: :param max: :param step: :return: """ x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() i = QInputDialog.getInt(x, title, label, val, min, max, step, ok) if ok: return i else: return False
def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200, 200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300, 50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw( "EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw( "EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0, 0, 1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000)
def sendMessage(self, schid, targetMode, toID): x = QWidget() clipboard = QApplication.clipboard().text(); _message = QInputDialog.getMultiLineText(x, "Enter long text here", "", clipboard) message = [_message[i:i + self.maxsize] for i in range(0, len(_message), self.maxsize)] if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL: for msg in message: error = ts3lib.requestSendChannelTextMsg(schid, "\n"+msg, toID) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT: for msg in message: error = ts3lib.requestSendPrivateTextMsg(schid, "\n"+msg, toID) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
def on_serverList_doubleClicked(self): try: row = self.serverList.selectedItems()[0].row() name = self.serverList.item(row, 0).text() ip = self.serverList.item(row, 5).text() haspw = True if self.serverList.item(row, 4).text() == "Yes" else False if haspw: x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) password = QInputDialog.getText(x, "Enter Server Password", "Password:"******"": return err, tab = ts3.guiConnect( ts3defines.PluginConnectTab. PLUGIN_CONNECT_TAB_NEW_IF_CURRENT_CONNECTED, name, ip, password if haspw else "", "TeamspeakUser", "", "", "", "", "", "", "", "", "") # print('item: {0} | row: {1} | item2: {2} |item2_column: {3} | text: {4}'.format(item, row, item2, item2.column(), item2.text())) # item. # item.setData(Qt.UserRole, 22); except: print(traceback.format_exc())
def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200,200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300,50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0,0,1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: schid = ts3.getCurrentServerConnectionHandlerID() error, ownid = ts3.getClientID(schid) if error == ts3defines.ERROR_ok: error, meta = ts3.getClientVariableAsString( schid, ownid, ts3defines.ClientProperties.CLIENT_META_DATA) if error == ts3defines.ERROR_ok: x = QWidget() meta = QInputDialog.getMultiLineText( x, "Change own Meta Data", "Meta Data:", meta) error = ts3.setClientSelfVariableAsString( schid, ts3defines.ClientProperties.CLIENT_META_DATA, meta) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own meta data!") t.show()
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) self.setWindowTitle('Inspect Element : : Developer Tools')
class ObjectEditWindow: UIFILE = "pymodules/objectedit/editobject.ui" ICON_FOLDER = "pymodules/objectedit/folder.png" ICON_OK = "pymodules/objectedit/ok-small.png" ICON_CANCEL = "pymodules/objectedit/cancel-small.png" 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 = [] def selected(self, ent, keepold=False): self.meshline.update_text(ent.prim.MeshID) self.soundline.update_text(ent.prim.SoundID) self.soundline.update_soundradius(ent.prim.SoundRadius) self.soundline.update_soundvolume(ent.prim.SoundVolume) self.updateAnimation(ent) self.updateMaterialTab(ent) self.updatingSelection = True self.update_guivals(ent) self.updatingSelection = False self.controller.soundRuler(ent) def deselected(self): self.meshline.update_text("") self.soundline.update_text("") self.updateAnimation() def update_guivals(self, ent): if ent is not None: self.update_posvals(ent.placeable.Position) self.update_scalevals(ent.placeable.Scale) self.update_rotvals(ent.placeable) #self.controller.updateSelectionBox(ent) #PositionAndOrientation(ent) def update_scalevals(self, scale): if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetScaleValues(scale.x(), scale.y(), scale.z()) def update_posvals(self, pos): if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetPosValues(pos.x(), pos.y(), pos.z()) def update_rotvals(self, placeable): # We use now pitch, yaw and roll we get directly from placeable # this ensures we don't have to do weird conversions with all # potential problems :) # TODO: figure out this shift - Looks like we need to give Ogre-style # info. Yaw in viewer is around z axis, but placeable gets # directly Ogre orientation x_val = math.degrees(placeable.Pitch) y_val = math.degrees(placeable.Yaw) z_val = math.degrees(placeable.Roll) if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetRotateValues(x_val, y_val, z_val) def updateAnimation(self, ent = None): # Hide by default self.animation_widget.setVisible(False) self.animationline.update_text("") self.animationline.update_animationrate(0.0) combobox = self.animationline.combobox combobox.clear() # Return if no mesh if not ent: return try: ent.mesh except: return # Show, update animation id and rate self.animation_widget.setVisible(True) self.animationline.update_text(ent.prim.AnimationPackageID) self.animationline.update_animationrate(ent.prim.AnimationRate) # Down update other elements if no asset ref in place if ent.prim.AnimationPackageID in (u'', '00000000-0000-0000-0000-000000000000'): return # Get anim component try: ac = ent.animationcontroller except: ent.GetOrCreateComponentRaw('EC_AnimationController') ac = ent.animationcontroller ac.SetNetworkSyncEnabled(False) ac.SetMeshEntity(ent.mesh) # Update rest of the ui current_animation = ent.prim.AnimationName available_animations = ac.GetAvailableAnimations() for anim in available_animations: combobox.addItem(anim) if current_animation in available_animations: idx = combobox.findText(current_animation) combobox.setCurrentIndex(idx) # Deactivate as this is the current data, no changes made self.animationline.deactivateButtons() def updateMaterialTab(self, ent): #ent = self.controller.active if ent is not None: self.clearDialogForm() qprim = ent.prim mats = qprim.Materials for i in range(len(mats)): index = str(i) tuple = mats[index] line = lines.UUIDEditLine(self.controller) line.update_text(tuple[1]) line.name = index asset_type = tuple[0] combobox = QComboBox() for text in PRIMTYPES.itervalues(): combobox.addItem(text) if PRIMTYPES.has_key(asset_type): realIndex = combobox.findText(PRIMTYPES[asset_type]) combobox.setCurrentIndex(realIndex) applyButton = self.getButton("materialApplyButton", self.ICON_OK, line, line.applyAction) cancelButton = self.getButton("materialCancelButton", self.ICON_CANCEL, line, line.cancelAction) line.index = index line.combobox = combobox line.connect('textEdited(QString)', applyButton.lineValueChanged) line.connect('textEdited(QString)', cancelButton.lineValueChanged) box = QHBoxLayout() box.addWidget(line) box.addWidget(applyButton) box.addWidget(cancelButton) self.materialTabFormWidget.materialFormLayout.addRow(combobox, box) def clearDialogForm(self): children = self.materialTabFormWidget.children() for child in children: if child.name != "materialFormLayout": #dont want to remove the actual form layout from the widget self.materialTabFormWidget.materialFormLayout.removeWidget(child) child.delete() children = self.materialTabFormWidget.findChildren("QHBoxLayout") for child in children: self.materialTabFormWidget.materialFormLayout.removeItem(child) child.delete() def getButton(self, name, iconname, line, action): size = QSize(20, 20) button = buttons.PyPushButton() icon = QIcon(QPixmap(iconname).scaled(size)) button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button.setMaximumSize(size) button.setMinimumSize(size) button.text = "" button.name = name button.setIcon(icon) button.setFlat(True) if action != None: button.connect('clicked()', action) if line != None: button.setEnabled(False) line.buttons.append(button) return button def getDoubleSpinBox(self, name, tooltip, line): spinner = QDoubleSpinBox() spinner.setValue(0.0) spinner.name = name spinner.toolTip = tooltip spinner.setEnabled(True) line.spinners.append(spinner) return spinner def getCombobox(self, name, tooltip, line): combobox = QComboBox() combobox.name = name combobox.toolTip = tooltip combobox.setEnabled(True) line.combobox = combobox return combobox
class MyTest(): def __init__(self): pass def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200,200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300,50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0,0,1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000) def animateSize(self): min_width = 1.0 max_width = 2.0 min_height = 1.0 max_height = 2.0 delta_width = max_width-min_width delta_height = max_height-min_height width = min_width + 0.5*delta_width + 0.5*delta_width*math.sin(time.time()*1.324) height = min_height + 0.5*delta_height + 0.5*delta_height*math.cos(time.time()*2.232) self.ec_billboard.SetSize(width, height) def animateText(self): text = str(float(time.time())) self.text_label.text = text self.ec_billboard.Refresh()
class ObjectEditWindow: UIFILE = "pymodules/objectedit/editobject.ui" ICON_FOLDER = "pymodules/objectedit/folder.png" ICON_OK = "pymodules/objectedit/ok-small.png" ICON_CANCEL = "pymodules/objectedit/cancel-small.png" 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 = [] def selected(self, ent, keepold=False): self.meshline.update_text(ent.prim.MeshID) self.soundline.update_text(ent.prim.SoundID) self.soundline.update_soundradius(ent.prim.SoundRadius) self.soundline.update_soundvolume(ent.prim.SoundVolume) self.updateAnimation(ent) self.updateMaterialTab(ent) self.updatingSelection = True self.update_guivals(ent) self.updatingSelection = False self.controller.soundRuler(ent) def deselected(self): self.meshline.update_text("") self.soundline.update_text("") self.updateAnimation() def update_guivals(self, ent): if ent is not None: self.update_posvals(ent.placeable.Position) self.update_scalevals(ent.placeable.Scale) self.update_rotvals(ent.placeable) #self.controller.updateSelectionBox(ent) #PositionAndOrientation(ent) def update_scalevals(self, scale): if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetScaleValues( scale.x(), scale.y(), scale.z()) def update_posvals(self, pos): if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetPosValues( pos.x(), pos.y(), pos.z()) def update_rotvals(self, placeable): # We use now pitch, yaw and roll we get directly from placeable # this ensures we don't have to do weird conversions with all # potential problems :) # TODO: figure out this shift - Looks like we need to give Ogre-style # info. Yaw in viewer is around z axis, but placeable gets # directly Ogre orientation x_val = math.degrees(placeable.Pitch) y_val = math.degrees(placeable.Yaw) z_val = math.degrees(placeable.Roll) if self.controller.cpp_python_handler != None: self.controller.cpp_python_handler.SetRotateValues( x_val, y_val, z_val) def updateAnimation(self, ent=None): # Hide by default self.animation_widget.setVisible(False) self.animationline.update_text("") self.animationline.update_animationrate(0.0) combobox = self.animationline.combobox combobox.clear() # Return if no mesh if not ent: return try: ent.mesh except: return # Show, update animation id and rate self.animation_widget.setVisible(True) self.animationline.update_text(ent.prim.AnimationPackageID) self.animationline.update_animationrate(ent.prim.AnimationRate) # Down update other elements if no asset ref in place if ent.prim.AnimationPackageID in ( u'', '00000000-0000-0000-0000-000000000000'): return # Get anim component try: ac = ent.animationcontroller except: ent.GetOrCreateComponentRaw('EC_AnimationController') ac = ent.animationcontroller ac.SetNetworkSyncEnabled(False) ac.SetMeshEntity(ent.mesh) # Update rest of the ui current_animation = ent.prim.AnimationName available_animations = ac.GetAvailableAnimations() for anim in available_animations: combobox.addItem(anim) if current_animation in available_animations: idx = combobox.findText(current_animation) combobox.setCurrentIndex(idx) # Deactivate as this is the current data, no changes made self.animationline.deactivateButtons() def updateMaterialTab(self, ent): #ent = self.controller.active if ent is not None: self.clearDialogForm() qprim = ent.prim mats = qprim.Materials for i in range(len(mats)): index = str(i) tuple = mats[index] line = lines.UUIDEditLine(self.controller) line.update_text(tuple[1]) line.name = index asset_type = tuple[0] combobox = QComboBox() for text in PRIMTYPES.itervalues(): combobox.addItem(text) if PRIMTYPES.has_key(asset_type): realIndex = combobox.findText(PRIMTYPES[asset_type]) combobox.setCurrentIndex(realIndex) applyButton = self.getButton("materialApplyButton", self.ICON_OK, line, line.applyAction) cancelButton = self.getButton("materialCancelButton", self.ICON_CANCEL, line, line.cancelAction) line.index = index line.combobox = combobox line.connect('textEdited(QString)', applyButton.lineValueChanged) line.connect('textEdited(QString)', cancelButton.lineValueChanged) box = QHBoxLayout() box.addWidget(line) box.addWidget(applyButton) box.addWidget(cancelButton) self.materialTabFormWidget.materialFormLayout.addRow( combobox, box) def clearDialogForm(self): children = self.materialTabFormWidget.children() for child in children: if child.name != "materialFormLayout": #dont want to remove the actual form layout from the widget self.materialTabFormWidget.materialFormLayout.removeWidget( child) child.delete() children = self.materialTabFormWidget.findChildren("QHBoxLayout") for child in children: self.materialTabFormWidget.materialFormLayout.removeItem(child) child.delete() def getButton(self, name, iconname, line, action): size = QSize(20, 20) button = buttons.PyPushButton() icon = QIcon(QPixmap(iconname).scaled(size)) button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button.setMaximumSize(size) button.setMinimumSize(size) button.text = "" button.name = name button.setIcon(icon) button.setFlat(True) if action != None: button.connect('clicked()', action) if line != None: button.setEnabled(False) line.buttons.append(button) return button def getDoubleSpinBox(self, name, tooltip, line): spinner = QDoubleSpinBox() spinner.setValue(0.0) spinner.name = name spinner.toolTip = tooltip spinner.setEnabled(True) line.spinners.append(spinner) return spinner def getCombobox(self, name, tooltip, line): combobox = QComboBox() combobox.name = name combobox.toolTip = tooltip combobox.setEnabled(True) line.combobox = combobox return combobox
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 = []
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 = []
def inputBox(title, text): x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) return QInputDialog.getText(x, title, text)
class MyTest(): def __init__(self): pass def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200, 200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300, 50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw( "EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw( "EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0, 0, 1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000) def animateSize(self): min_width = 1.0 max_width = 2.0 min_height = 1.0 max_height = 2.0 delta_width = max_width - min_width delta_height = max_height - min_height width = min_width + 0.5 * delta_width + 0.5 * delta_width * math.sin( time.time() * 1.324) height = min_height + 0.5 * delta_height + 0.5 * delta_height * math.cos( time.time() * 2.232) self.ec_billboard.SetSize(width, height) def animateText(self): text = str(float(time.time())) self.text_label.text = text self.ec_billboard.Refresh()