Py学习  »  vonDoomhammer  »  全部回复
回复总数  1

据我所知,土生土长的玛雅人使用 Code Page 1252 Windows Latin 1 (ANSI) 如前所述的字符集(至少在Windows上…) here ,而且在一些拉面之后,这些*看起来都像广告上说的那样工作。

我很想看到一个解释如何改变它和访问op所寻找的东西的答案,但是作为一个真正想要更多特殊字符的人的替代方案,我建议您学习pyside/qt来构建您的ui。

告诫

  1. 在制作“简单的东西”时,需要更多的样板和设置
  2. 一些mayaControl没有直接的qt实现( gradientControlNoAttr 是一个新的发现,并且是一个很好的例子)
  3. 示例是在假定用户已安装并使用 Qt.py

让我们直接进入:

import maya.cmds as cmds
import maya.OpenMayaUI as omui
from Qt import QtCore, QtGui
from Qt.QtWidgets import *
from shiboken import wrapInstance

def maya_main_window():
    main_window_ptr = omui.MQtUtil.mainWindow()
    return wrapInstance(long(main_window_ptr), QWidget)

class TestUi(QDialog):
    def __init__(self, parent=maya_main_window()):
        super(TestUi, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

    def create(self):
        self.setWindowTitle("TestUi : Unicode")
        self.setWindowFlags(QtCore.Qt.Tool)

        self.create_controls()
        self.create_layout()
        self.create_connections()

    def create_controls(self):
        """
        Create the widgets for the dialog.
        """
        # using "Python source code" unicode values
        # ie: https://www.fileformat.info/info/unicode/char/2191/index.htm
        self.up_button = QPushButton(u'\u2191')
        self.down_button = QPushButton(u'\u2193')
        self.left_button = QPushButton(u'\u2190')
        self.right_button = QPushButton(u'\u2192')

    def create_layout(self):
        """
        Create the layouts & add widgets
        """
        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(6, 6, 6, 6)

        main_layout.addWidget(self.up_button)
        main_layout.addWidget(self.down_button)
        main_layout.addWidget(self.left_button)
        main_layout.addWidget(self.right_button)

        main_layout.addStretch()
        self.setLayout(main_layout)


    def create_connections(self):
        """
        Create the signal/slot connections
        """
        self.up_button.clicked.connect(self.on_button_pressed)
        self.down_button.clicked.connect(self.on_button_pressed)
        self.left_button.clicked.connect(self.on_button_pressed)
        self.right_button.clicked.connect(self.on_button_pressed)

    def on_button_pressed(self):
        print "Button Pressed"

def LaunchUI():
    if __name__ == "__main__":
        # Development workaround for PySide winEvent error (Maya 2014)
        # Make sure the UI is deleted before recreating
        try:
            test_ui.deleteLater()
            test_ui.close()
        except:
            pass
         # Create minimal UI object
        test_ui = TestUi()
        # Delete the UI if errors occur to avoid causing winEvent
        # and event errors (in Maya 2014)
        try:
            test_ui.create()
            test_ui.show()
        except:
            test_ui.deleteLater()
            traceback.print_exc()
LaunchUI()

有很多东西要打开,但却没有得到巨大的回报,但相关的信息却生活在“创建控制”之下。

demonstration of unicode in Maya UI via PySide