|
|
|
@ -2336,6 +2336,7 @@ def _print (*args):
|
|
|
|
|
|
|
|
|
|
def show_msg(text, title = None, parent = None):
|
|
|
|
|
msgBox = qt.QMessageBox(parent)
|
|
|
|
|
#DEBUG: want traceback? force error there.
|
|
|
|
|
# raise Exception
|
|
|
|
|
if title:
|
|
|
|
|
msgBox.setWindowTitle(title)
|
|
|
|
@ -2344,16 +2345,19 @@ def show_msg(text, title = None, parent = None):
|
|
|
|
|
if not text:
|
|
|
|
|
return 1
|
|
|
|
|
if not type(text) in [str]:
|
|
|
|
|
temp = ''
|
|
|
|
|
for i in text:
|
|
|
|
|
#DEBUG: want traceback? force error there.
|
|
|
|
|
# for i in str(text):
|
|
|
|
|
try:
|
|
|
|
|
# temp += str(i).decode('utf-8')+' '
|
|
|
|
|
temp += str(i) + ' '
|
|
|
|
|
except (UnicodeEncodeError, UnicodeDecodeError):
|
|
|
|
|
temp += str(i) + ' '
|
|
|
|
|
text = temp
|
|
|
|
|
|
|
|
|
|
if hasattr(text, '__iter__'):
|
|
|
|
|
#print(f'{text} is iterable')
|
|
|
|
|
temp = ''
|
|
|
|
|
for i in text:
|
|
|
|
|
try:
|
|
|
|
|
# temp += str(i).decode('utf-8')+' '
|
|
|
|
|
temp += str(i) + ' '
|
|
|
|
|
except (UnicodeEncodeError, UnicodeDecodeError):
|
|
|
|
|
temp += str(i) + ' '
|
|
|
|
|
text = temp
|
|
|
|
|
else:
|
|
|
|
|
text = str(text)
|
|
|
|
|
msgBox.setText(text)
|
|
|
|
|
msgBox.setStandardButtons(qt.QMessageBox.Ok)
|
|
|
|
|
msgBox.setWindowIcon(get_icon('calculate-install.svg'))
|
|
|
|
@ -2648,7 +2652,6 @@ class ImageLabel(qt.QLabel):
|
|
|
|
|
image_conf = os.path.join(image_path, 'conf')
|
|
|
|
|
|
|
|
|
|
repeat_dict = {'no' : 'no-repeat', 'x' : 'repeat-x'}
|
|
|
|
|
|
|
|
|
|
for line in readLinesFile(image_conf):
|
|
|
|
|
list_data = line.split()
|
|
|
|
|
if len (list_data) < 2:
|
|
|
|
@ -2664,6 +2667,7 @@ class ImageLabel(qt.QLabel):
|
|
|
|
|
def resize_image(source_path, height, output_path):
|
|
|
|
|
convert_cmd = getProgPath('/usr/bin/convert')
|
|
|
|
|
identify_cmd = getProgPath('/usr/bin/identify')
|
|
|
|
|
|
|
|
|
|
def convert_image(source, res, target):
|
|
|
|
|
command = [convert_cmd, "-quality", "100",
|
|
|
|
|
source, "-resize", "%s" % res,
|
|
|
|
@ -2671,10 +2675,12 @@ class ImageLabel(qt.QLabel):
|
|
|
|
|
target]
|
|
|
|
|
#"-strip", "-gravity", "center",
|
|
|
|
|
#"-crop", "%s+0+0" % res, target]
|
|
|
|
|
|
|
|
|
|
convert = process(*command, stderr=STDOUT)
|
|
|
|
|
if convert.success():
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def get_image_resolution(source):
|
|
|
|
|
identify = process(identify_cmd, "-format", "%w %h", source)
|
|
|
|
|
if identify.success():
|
|
|
|
@ -2683,11 +2689,15 @@ class ImageLabel(qt.QLabel):
|
|
|
|
|
return int(swidth), int(sheight)
|
|
|
|
|
return None, None
|
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
|
|
cx, cy = get_image_resolution(source_path)
|
|
|
|
|
|
|
|
|
|
if cx and cy:
|
|
|
|
|
if convert_image(source_path, "{}x{}".format(cx, height),
|
|
|
|
|
output_path):
|
|
|
|
|
|
|
|
|
|
return get_image_resolution(output_path)
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if len(list_data) == 3:
|
|
|
|
|