Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
thread.stop(0.1)
except Exception:
pass
t5 = time.process_time()
if 1: # EKR
g.pr('\nMainWindowShim.closeEvent 2')
g.pr('stage 1: %5.2f' % (t2-t1))
g.pr('stage 2: shells: %5.2f' % (t3-t2))
g.pr('stage 3: tools: %5.2f' % (t4-t3))
g.pr('stage 4: threads: %5.2f' % (t5-t4))
# Proceed as normal
QtWidgets.QMainWindow.closeEvent(self, event)
# Harder exit to prevent segfault. Not really a solution,
# but it does the job until Pyside gets fixed.
if sys.version_info >= (3,3,0): # and not restarting:
if hasattr(os, '_exit'):
os._exit(0)
#@+node:ekr.20190402101635.1: *3* MainWindowShim.monkey_patch_leo
def create_input_area(self, layout):
# Create the Label
label = QtWidgets.QLabel()
label.setText('Debugger command:')
# Create the editor.
self.line_edit = w = QtWidgets.QLineEdit()
w.setStyleSheet('background: white; color: black;')
w.returnPressed.connect(self.debug_input)
# Add the widgets to a new layout.
layout2 = QtWidgets.QVBoxLayout()
layout2.addWidget(label)
layout2.addWidget(w)
layout.addLayout(layout2)
#@+node:ekr.20181006154605.1: *4* create_output_area
def print_doc(self, doc):
dialog = QtWidgets.QPrintDialog()
if dialog.exec_() == QtWidgets.QDialog.Accepted:
doc.print_(dialog.printer())
#@+node:peckj.20130513115943.22662: *4* print preview dialog
pen = QtGui.QPen()
self.line.setZValue(0)
if not hierarchyLink:
self.setZValue(1)
pen.setWidth(2)
else:
self.setZValue(0)
pen.setColor(QtGui.QColor(240,240,240))
pen.setWidth(2) # (0.5)
self.line.setPen(pen)
self.addToGroup(self.line)
self.head = QtWidgets.QGraphicsPolygonItem()
if hierarchyLink:
self.head.setBrush(QtGui.QBrush(QtGui.QColor(180,180,180)))
else:
self.head.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0)))
self.head.setPen(QtGui.QPen(QtConst.NoPen))
self.addToGroup(self.head)
#@+node:bob.20110119123023.7406: *3* mousePressEvent
def __init__(self, c, parent, root):
QtWidgets.QScrollArea.__init__(self, parent)
self.qtree = QtWidgets.QTreeWidget()
self.root = root
self.busy = False
#self.root_pos = leoNodes.Position(root.children[0], 0)
self.gnx_decluttered = {} # keeps cache of decluttering nodes
self.declutter_patterns = None
self.c = c
# the following two ivars allows to skip expensive operation
# drawing_items(self.root)
# for tree redraw after scrolling there is no need to recompute
# list of visible items.
# Only on expand, contract and other commands that change the outline
# we have to recalculate this list
self._visibles_version = 0
self._last_visibles_version = -1
def construct_complex_document(self, nodes, heads=False):
doc = QtWidgets.QTextDocument()
doc.setDefaultStyleSheet(self.stylesheet)
contents = ''
for n in nodes:
if heads:
contents += '<h1>%s</h1>\n' % (self.sanitize_html(n.h))
contents += '<pre>%s</pre>\n' % (self.sanitize_html(n.b))
doc.setHtml(contents)
return doc
#@+node:peckj.20130513115943.22661: *4* print dialog
def _build_gui(self):
self.w = w = QtWidgets.QWidget()
w.setObjectName('show_livecode')
w.setLayout(QtWidgets.QVBoxLayout())
self.status = QtWidgets.QLabel()
w.layout().addWidget(self.status)
self.text = QtWidgets.QTextBrowser()
w.layout().addWidget(self.text)
h = QtWidgets.QHBoxLayout()
w.layout().addLayout(h)
self.activate = QtWidgets.QPushButton("Stop")
self.activate.setToolTip("Start / stop live code display")
h.addWidget(self.activate)
self.activate.clicked.connect(lambda checked: self.toggle_active())
b = QtWidgets.QPushButton("Run here")
b.setToolTip("Show live code for this node")
h.addWidget(b)
def __init__(self, parent=None, n=3, columns=3):
"""set up
:Parameters:
- `self`: the widget
- `n`: number of months to display
- `columns`: months to display before start a new row
"""
QtWidgets.QDateEdit.__init__(self, parent)
self.setCalendarPopup(True)
self.cw = QNCalendarWidget(n=n, columns=columns)
self.setCalendarWidget(self.cw)
def __init__(self, parent, title, text, entries):
self.entries = entries
QtWidgets.QDialog.__init__(self, parent)
vbox = QtWidgets.QVBoxLayout()
sa = QtWidgets.QScrollArea()
salo = QtWidgets.QVBoxLayout()
frame = QtWidgets.QFrame()
frame.setLayout(salo)
self.buttons = []
for entry in entries:
hbox = QtWidgets.QHBoxLayout()
cb = QtWidgets.QCheckBox(entry[0])
self.buttons.append(cb)
if entry[1]:
cb.setCheckState(QtCore.Qt.Checked)
hbox.addWidget(cb)
salo.addLayout(hbox)
sa.setWidget(frame)
vbox.addWidget(sa)
hbox = QtWidgets.QHBoxLayout()
ok = QtWidgets.QPushButton("Ok")
cancel = QtWidgets.QPushButton("Cancel")
def __init__(self, owner):
'''Ctor for backlinkQtUI class.'''
self.owner = owner
QtWidgets.QWidget.__init__(self)
uiPath = g.os_path_join(g.app.leoDir, 'plugins', 'Backlink.ui')
form_class, base_class = uic.loadUiType(uiPath)
self.owner.c.frame.log.createTab('Links', widget = self)
self.UI = form_class()
self.UI.setupUi(self)
u = self.UI
o = self.owner
# Compatible with PyQt5
u.markBtn.clicked.connect(o.mark)
u.swapBtn.clicked.connect(o.swap)
u.linkBtn.clicked.connect(self.linkClicked)
u.rescanBtn.clicked.connect(o.loadLinksInt)
u.dirLeftBtn.clicked.connect(self.dirClicked)
u.dirRightBtn.clicked.connect( self.dirClicked)
u.linkList.itemClicked.connect(self.listClicked)
u.deleteBtn.stateChanged.connect(o.deleteSet)