Skip to content

Commit 3f58142

Browse files
committed
[pyqgis-console] increases height of the row in QListView and QTreeWidget for Windows OS
- small fixes for the run script command
1 parent a7923a1 commit 3f58142

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

python/console/console_editor.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,20 @@ def createTempFile(self):
485485
return tmpFileName
486486

487487
def _runSubProcess(self, filename, tmp=False):
488-
dir, name = os.path.split(unicode(filename))
488+
dir = QFileInfo(filename).path()
489+
file = QFileInfo(filename).fileName()
490+
name = QFileInfo(filename).baseName()
489491
if dir not in sys.path:
490492
sys.path.append(dir)
493+
if name in sys.modules:
494+
reload(sys.modules[name])
491495
try:
492496
## set creationflags for running command without shell window
493497
if sys.platform.startswith('win'):
494-
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
498+
p = subprocess.Popen(['python', unicode(filename)], shell=False, stdin=subprocess.PIPE,
495499
stderr=subprocess.PIPE, stdout=subprocess.PIPE, creationflags=0x08000000)
496500
else:
497-
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
501+
p = subprocess.Popen(['python', unicode(filename)], shell=False, stdin=subprocess.PIPE,
498502
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
499503
out, _traceback = p.communicate()
500504

@@ -511,18 +515,18 @@ def _runSubProcess(self, filename, tmp=False):
511515
raise e
512516
if tmp:
513517
tmpFileTr = QCoreApplication.translate('PythonConsole', ' [Temporary file saved in ')
514-
name = name + tmpFileTr + dir + ']'
518+
file = file + tmpFileTr + dir + ']'
515519
if _traceback:
516-
msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: %1').arg(name)
520+
msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: %1').arg(file)
517521
print "## %s" % datetime.datetime.now()
518-
print msgTraceTr
522+
print unicode(msgTraceTr)
519523
sys.stderr.write(_traceback)
520524
p.stderr.close()
521525
else:
522526
msgSuccessTr = QCoreApplication.translate('PythonConsole',
523-
'## Script executed successfully: %1').arg(name)
527+
'## Script executed successfully: %1').arg(file)
524528
print "## %s" % datetime.datetime.now()
525-
print msgSuccessTr
529+
print unicode(msgSuccessTr)
526530
sys.stdout.write(out)
527531
p.stdout.close()
528532
del p
@@ -602,7 +606,9 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
602606
#source = open(filename, 'r').read() + '\n'
603607
if type(source) == type(u""):
604608
source = source.encode('utf-8')
605-
compile(source, str(filename), 'exec')
609+
if type(filename) == type(u""):
610+
filename = filename.encode('utf-8')
611+
compile(source, filename, 'exec')
606612
except SyntaxError, detail:
607613
s = traceback.format_exception_only(SyntaxError, detail)
608614
fn = detail.filename
@@ -1126,6 +1132,8 @@ def listObject(self, tab):
11261132
else:
11271133
classItem.setText(0, name)
11281134
classItem.setToolTip(0, name)
1135+
if sys.platform.startswith('win'):
1136+
classItem.setSizeHint(0, QSize(18, 18))
11291137
classItem.setText(1, str(class_data.lineno))
11301138
iconClass = QgsApplication.getThemeIcon("console/iconClassTreeWidgetConsole.png")
11311139
classItem.setIcon(0, iconClass)
@@ -1137,6 +1145,8 @@ def listObject(self, tab):
11371145
methodItem.setToolTip(0, meth)
11381146
iconMeth = QgsApplication.getThemeIcon("console/iconMethodTreeWidgetConsole.png")
11391147
methodItem.setIcon(0, iconMeth)
1148+
if sys.platform.startswith('win'):
1149+
methodItem.setSizeHint(0, QSize(18, 18))
11401150
classItem.addChild(methodItem)
11411151
dictObject[meth] = lineno
11421152
self.parent.listClassMethod.addTopLevelItem(classItem)
@@ -1149,6 +1159,8 @@ def listObject(self, tab):
11491159
funcItem.setToolTip(0, func_name)
11501160
iconFunc = QgsApplication.getThemeIcon("console/iconFunctionTreeWidgetConsole.png")
11511161
funcItem.setIcon(0, iconFunc)
1162+
if sys.platform.startswith('win'):
1163+
funcItem.setSizeHint(0, QSize(18, 18))
11521164
dictObject[func_name] = data.lineno
11531165
self.parent.listClassMethod.addTopLevelItem(funcItem)
11541166
if found:

python/console/console_sci.py

+2
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ def _reloadHistory(self):
586586
self.model.clear()
587587
for i in self.parent.history:
588588
item = QStandardItem(i)
589+
if sys.platform.startswith('win'):
590+
item.setSizeHint(QSize(18, 18))
589591
self.model.appendRow(item)
590592

591593
self.listView.setModel(self.model)

0 commit comments

Comments
 (0)