2017-04-23 2 views
0

PySide(python)を使って簡単なテキストエディタを設定しています。私は、解放のモノラルとしてデフォルトのフォントを設定したいと思います。私はフォントを変更することに興味がないので、メインオブジェクトのフォントを一度設定するだけです。どうすればいい?デフォルトのフォントのメインウィンドウを設定しますpydide

これは私がメインウィンドウを実装するために書いたコードです:

class MainWindow(QMainWindow): 
    def __init__(self): 
     super(MainWindow, self).__init__() 
     self.initGUI() 

    def initGUI(self): 
     self.setWindowTitle("ScribblerSeq") 
     self.setWindowIcon(QIcon('./icon/appicon.png')) 
     self.setGeometry(1200, 1800, 800, 600) 
     self.statusLabel = QLabel('Showing Progress') 
     self.CreateProgessBar() 
     self.CreateStatusBar() 
     self.center() 
     self.SetupComponents() 
     self.show() 

は、スタイルシートを使用して、あなたに

答えて

1

に感謝:

main_window = MainWindow() 

CURRENT_PATH = os.path.dirname(__file__) 
style_path = os.path.join(CURRENT_PATH, 'style', 'app.css') 

# load and set stylesheet 
with open(style_path, "r") as fh: 
    main_window.setStyleSheet(fh.read()) 

app.css:

* { font-family: "Times New Roman", Times, serif;} 

をextを使う利点あなたが望むなら、後で簡単に変更/追加することができます。

関連する問題