This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
u""" | |
CustomScriptEditor2.py | |
:Author: | |
oki yoshihiro | |
okiyoshihiro.job@gmail.com | |
:Version: -1.0- | |
:Date: 2024/05/09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 標準ライブラリ ################################################################# | |
from functools import partial | |
from pprint import pprint | |
from typing import Tuple, List | |
# サードパーティライブラリ ######################################################### | |
# from maya import OpenMayaUI, cmds | |
from PySide2.QtWidgets import (QApplication, QComboBox, QGridLayout, | |
QMainWindow, QWidget, QHBoxLayout, QVBoxLayout, | |
QPushButton, QAction, QFrame, QLabel, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtWidgets import (QWidget, QVBoxLayout, QPushButton, | |
QMainWindow, QApplication | |
) | |
from PySide2.QtCore import Qt | |
from maya import OpenMayaUI | |
from shiboken2 import wrapInstance | |
def maya_main_window(): | |
main_window_ptr = OpenMayaUI.MQtUtil.mainWindow() | |
return wrapInstance(int(main_window_ptr), QMainWindow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .. import YO_jointDrawStyle_change | |
from .. import YO_jointRadiusSlider | |
としています。 | |
現状は、存在しなければ、エラーでプログラムが止まってしまいます。 | |
存在しないくても、エラーでプログラムが止まらずに、そのまま進んでもらうためには、 | |
どういった記述を追記する必要がありますか? | |
ChatGPT | |
Pythonでは、モジュールやパッケージが存在しない場合でもエラーが発生しないようにするために、try-except文を使用することができます。具体的には、tryブロック内でインポート文を実行し、ModuleNotFoundErrorなどの例外が発生した場合にexceptブロックで処理を行います。 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
プロパティ。。? | |
引数を持たない関数をシグナルのスロットとして使用することも可能 | |
# PySide2.QtWidgets.QTabWidget 組み込み関数 を使用した | |
# tab クリックで、コンテナ のある フレーム の高さを再計算するシグナル の埋め込み | |
tab_wid_.tabBarClicked.connect(self.tabClicked) | |
です。 | |
現状、 | |
def tabClicked(self, index): | |
print(f'Tab clicked: {index}\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 親layout | |
# ├ 親layout.addLayout(子layout) | |
# └ 親layout.addLayout(子layout) | |
# のパターン | |
# QHBoxLayoutを2つ用意しています。 | |
# これらを、QVBoxLayout1つでまとめたいと思います。 | |
# 一番理解しやすく視認性のある、簡単な記述をください。 | |
# 但し、 | |
# def createUI(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PySide2_sample_main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = r'C:\Users\oki44\Documents\maya\2018\myTool\selfMade_python' | |
if path not in sys.path: | |
print(u'now, add a path.....{}'.format(path)) | |
sys.path.append(path) | |
else: | |
print(u'already, added a path.....{}'.format(path)) | |
# 強制的にパスを通して、その直下にあるフォルダ内のモジュールを見るためには、 | |
# __init__.py (つまり、そのフォルダはパッケージですよ!!と認識させる必要がある) | |
# が必要である |
NewerOlder