src/eric7/UI/UserInterface.py

branch
eric7
changeset 10482
72d9b5ea39b4
parent 10475
ee41fab001f2
child 10500
40fc136e7002
equal deleted inserted replaced
10481:9aea3575bd16 10482:72d9b5ea39b4
7 Module implementing the main user interface. 7 Module implementing the main user interface.
8 """ 8 """
9 9
10 import contextlib 10 import contextlib
11 import datetime 11 import datetime
12 import enum
12 import functools 13 import functools
13 import getpass 14 import getpass
14 import json 15 import json
15 import logging 16 import logging
16 import os 17 import os
172 """ 173 """
173 self.buffer += str(s) 174 self.buffer += str(s)
174 self.__nWrite(self.__bufferedWrite()) 175 self.__nWrite(self.__bufferedWrite())
175 176
176 177
178 class UserInterfaceSide(enum.Enum):
179 """
180 Class defining the supported sides of the user interface.
181 """
182
183 Left = 1
184 Bottom = 2
185 Right = 3
186
187
177 class UserInterface(EricMainWindow): 188 class UserInterface(EricMainWindow):
178 """ 189 """
179 Class implementing the main user interface. 190 Class implementing the main user interface.
180 191
181 @signal appendStderr(str) emitted to write data to stderr logger 192 @signal appendStderr(str) emitted to write data to stderr logger
198 mainPasswordChanged = pyqtSignal(str, str) 209 mainPasswordChanged = pyqtSignal(str, str)
199 onlineStateChanged = pyqtSignal(bool) 210 onlineStateChanged = pyqtSignal(bool)
200 211
201 maxFilePathLen = 100 212 maxFilePathLen = 100
202 maxMenuFilePathLen = 75 213 maxMenuFilePathLen = 75
203
204 # TODO: change this to an enum
205 LeftSide = 1
206 BottomSide = 2
207 RightSide = 3
208 214
209 ErrorLogFileName = "eric7_error.log" 215 ErrorLogFileName = "eric7_error.log"
210 216
211 def __init__( 217 def __init__(
212 self, 218 self,
1466 def addSideWidget(self, side, widget, icon, label): 1472 def addSideWidget(self, side, widget, icon, label):
1467 """ 1473 """
1468 Public method to add a widget to the sides. 1474 Public method to add a widget to the sides.
1469 1475
1470 @param side side to add the widget to 1476 @param side side to add the widget to
1471 @type int (one of UserInterface.LeftSide, UserInterface.BottomSide, 1477 @type UserInterfaceSide
1472 UserInterface.RightSide)
1473 @param widget reference to the widget to add 1478 @param widget reference to the widget to add
1474 @type QWidget 1479 @type QWidget
1475 @param icon icon to be used 1480 @param icon icon to be used
1476 @type QIcon 1481 @type QIcon
1477 @param label label text to be shown 1482 @param label label text to be shown
1478 @type str 1483 @type str
1479 """ 1484 """
1480 if side in [ 1485 if self.__layoutType == "Toolboxes":
1481 UserInterface.LeftSide, 1486 if side == UserInterfaceSide.Left:
1482 UserInterface.BottomSide, 1487 self.lToolbox.addItem(widget, icon, label)
1483 UserInterface.RightSide, 1488 elif side == UserInterfaceSide.Bottom:
1484 ]: 1489 self.hToolbox.addItem(widget, icon, label)
1485 if self.__layoutType == "Toolboxes": 1490 elif side == UserInterfaceSide.Right:
1486 if side == UserInterface.LeftSide: 1491 self.rToolbox.addItem(widget, icon, label)
1487 self.lToolbox.addItem(widget, icon, label) 1492 elif self.__layoutType == "Sidebars":
1488 elif side == UserInterface.BottomSide: 1493 if side == UserInterfaceSide.Left:
1489 self.hToolbox.addItem(widget, icon, label) 1494 self.leftSidebar.addTab(widget, icon, label)
1490 elif side == UserInterface.RightSide: 1495 elif side == UserInterfaceSide.Bottom:
1491 self.rToolbox.addItem(widget, icon, label) 1496 self.bottomSidebar.addTab(widget, icon, label)
1492 elif self.__layoutType == "Sidebars": 1497 elif side == UserInterfaceSide.Right:
1493 if side == UserInterface.LeftSide: 1498 if self.rightSidebar:
1499 self.rightSidebar.addTab(widget, icon, label)
1500 else:
1494 self.leftSidebar.addTab(widget, icon, label) 1501 self.leftSidebar.addTab(widget, icon, label)
1495 elif side == UserInterface.BottomSide:
1496 self.bottomSidebar.addTab(widget, icon, label)
1497 elif side == UserInterface.RightSide:
1498 if self.rightSidebar:
1499 self.rightSidebar.addTab(widget, icon, label)
1500 else:
1501 self.leftSidebar.addTab(widget, icon, label)
1502 1502
1503 def removeSideWidget(self, widget): 1503 def removeSideWidget(self, widget):
1504 """ 1504 """
1505 Public method to remove a widget added using addSideWidget(). 1505 Public method to remove a widget added using addSideWidget().
1506 1506

eric ide

mercurial