扩大Spyder的编辑区域

作者 : RY    标签: spyder
切换行号 全选 下载代码

通过缩小Spyder的工具栏图标、菜单、状态栏,隐藏DockWidget的标题栏等,扩大代码的编辑区域,以适合分辨率较低的屏幕使用。为了运行此程序,首先打开Spyder的Internal Console,然后在其中通过右键菜单中的Run...运行本程序。

001import gc
002from PyQt4.QtCore import QSize
003from PyQt4.QtGui import QWidget, QIcon
004from PyQt4 import QtGui
005from PyQt4.QtCore import Qt
006 
007Settings = {
008    "tabcolor":"#17B6FF",
009    "fontsize":"10px"
010}
011 
012def find_objects(klass_name):
013    objs = []
014    if isinstance(klass_name, str):
015        klass_name = [klass_name]
016    for o in gc.get_objects():
017        if type(o).__name__ in klass_name:
018            objs.append(o)
019    return objs
020     
021for toolbar in find_objects(["QToolBar", "WorkingDirectory"]):
022    toolbar.setIconSize(QSize(16, 16))
023    toolbar.setMaximumHeight(24)
024     
025for dock in find_objects("QDockWidget"):
026    title_widget = QWidget()
027    dock.setTitleBarWidget(title_widget)
028     
029app = find_objects("QApplication")[0]
030app.setStyle(QtGui.QStyleFactory.create("plastique"))
031 
032stylesheet = """
033QTabBar{
034    text-align: left;
035    font-size:10px;
036    icon-size:0px;
037}
038 
039QTabBar::tab {
040    padding: 2px;
041    font-size:10px;
042    border-top-left-radius: 1px;
043    border-top-right-radius: 1px;
044    border: 1px solid #C4C4C3;
045    margin:0px;
046    spacing:0px;
047    text-align: left;
048    max-height:150px;
049}
050 
051QTabBar::tab:top{
052    padding-left:3px;
053    padding-right:3px;
054}
055 
056QTabBar::tab:selected {
057     background: %(tabcolor)s;
058     padding:1px;
059}
060 
061QMenuBar{
062    font-size:%(fontsize)s;
063}
064 
065QToolBar{
066    padding:1px;
067    height:14px;
068}
069 
070QToolBar::handle{
071    width:0px;
072}
073 
074QToolBar QComboBox{
075    font-size:%(fontsize)s;
076    height:12px;
077}
078 
079QStatusBar QLabel{
080    font-size:%(fontsize)s;
081}
082 
083QSplitter::handle {
084    width:2px;
085}
086 
087QTreeView{
088    font-size:%(fontsize)s;
089}
090 
091QToolTip{
092    color:black;
093}
094 
095QScrollBar:vertical {
096     width: 6px;
097     padding:0px;
098     border:0px;
099     background-color:gray;
100 }
101  
102QScrollBar::handle:vertical {
103     background: %(tabcolor)s;
104     min-height:30px;
105}
106 
107QScrollBar:horizontal {
108     height: 6px;
109     padding:0px;
110     border:0px;
111     background-color:gray;
112}
113  
114QScrollBar::handle:horizontal {
115     background: %(tabcolor)s;
116     min-width:30px;
117}
118""" % Settings
119 
120app.setStyleSheet(stylesheet)

loading...