1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/nachifur-MulimgViewer

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
main.py 54 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
nachifur Отправлено 14.06.2022 20:08 c5fe2c4
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
from tkinter.messagebox import NO
import wx
from main_gui import MulimgViewerGui
import numpy as np
from about import About
from utils_img import ImgManager
from index_table import IndexTable
from pathlib import Path
import copy
from utils import get_resource_path, MyTestEvent
import platform
import requests
import threading
class MulimgViewer (MulimgViewerGui):
def __init__(self, parent, UpdateUI, get_type, default_path=None):
super().__init__(parent)
self.create_ImgManager()
self.UpdateUI = UpdateUI
self.get_type = get_type
acceltbl = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_UP,
self.menu_up.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_DOWN,
self.menu_down.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_RIGHT,
self.menu_right.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_LEFT,
self.menu_left.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_DELETE,
self.menu_delete_box.GetId())
])
self.SetAcceleratorTable(acceltbl)
# self.img_Sizer = self.scrolledWindow_img.GetSizer()
self.Bind(wx.EVT_CLOSE, self.close)
# self.Bind(wx.EVT_PAINT, self.OnPaint)
# parameter
self.out_path_str = ""
self.img_name = []
self.position = [0, 0]
self.Uint = self.scrolledWindow_img.GetScrollPixelsPerUnit()
self.Status_number = self.m_statusBar1.GetFieldsCount()
self.img_size = [-1, -1]
self.width = 1000
self.height = 600
self.start_flag = 0
self.x = -1
self.x_0 = -1
self.y = -1
self.y_0 = -1
self.color_list = []
self.box_id = -1
self.xy_magnifier = []
self.show_scale_proportion = 0
self.key_status = {"shift": 0, "ctrl": 0, "alt": 0}
self.indextablegui = None
self.aboutgui = None
self.icon = wx.Icon(get_resource_path(
'mulimgviewer.ico'), wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)
self.m_statusBar1.SetStatusWidths([-2, -1, -4, -4])
self.set_title_font()
self.hidden_flag = 0
# Different platforms may need to adjust the width of the scrolledWindow_set
sys_platform = platform.system()
if sys_platform.find("Windows") >= 0:
self.width_setting = 300
elif sys_platform.find("Linux") >= 0:
self.width_setting = 280
elif sys_platform.find("Darwin") >= 0:
self.width_setting = 350
else:
self.width_setting = 300
self.SashPosition = self.width-self.width_setting
self.m_splitter1.SetSashPosition(self.SashPosition)
self.split_changing = False
self.width_setting_ = self.width_setting
# Draw color to box
self.colourPicker_draw.Bind(
wx.EVT_COLOURPICKER_CHANGED, self.draw_color_change)
# Check the software version
self.myEVT_MY_TEST = wx.NewEventType()
EVT_MY_TEST = wx.PyEventBinder(self.myEVT_MY_TEST, 1)
self.Bind(EVT_MY_TEST, self.myEVT_MY_TEST_OnHandle)
self.version = "v3.9.7"
self.check_version()
# open default path
if default_path:
self.ImgManager.init(default_path, 2)
self.show_img_init()
self.ImgManager.set_action_count(0)
self.show_img()
def myEVT_MY_TEST_OnHandle(self, event):
self.about_gui(None, update=True, new_version=event.GetEventArgs())
def check_version(self):
t1 = threading.Thread(target=self.run, args=())
t1.setDaemon(True)
t1.start()
def run(self):
url = "https://api.github.com/repos/nachifur/MulimgViewer/releases/latest"
try:
resp = requests.get(url)
resp.encoding = 'UTF-8'
if resp.status_code == 200:
output = resp.json()
if output["tag_name"] == self.version:
# print("No need to update!")
pass
else:
# print(output["tag_name"])
# print("Need to update!")
evt = MyTestEvent(self.myEVT_MY_TEST)
evt.SetEventArgs(output["tag_name"])
wx.PostEvent(self, evt)
except:
pass
def set_title_font(self):
font_path = Path("font")/"using"
font_path = Path(get_resource_path(str(font_path)))
files_name = [f.stem for f in font_path.iterdir()]
files_name = np.sort(np.array(files_name)).tolist()
for file_name in files_name:
file_name = file_name.split("_", 1)[1]
file_name = file_name.replace("-", " ")
self.title_font.Append(file_name)
self.title_font.SetSelection(0)
font_paths = [str(f) for f in font_path.iterdir()]
self.font_paths = np.sort(np.array(font_paths)).tolist()
def frame_resize(self, event):
self.auto_layout(frame_resize=True)
def open_all_img(self, event):
input_mode = self.choice_input_mode.GetSelection()
if input_mode == 0:
self.one_dir_mul_img(event)
elif input_mode == 1:
self.one_dir_mul_dir_auto(event)
elif input_mode == 2:
self.one_dir_mul_dir_manual(event)
elif input_mode == 3:
self.onefilelist(event)
def close(self, event):
if self.get_type() == -1:
self.Destroy()
else:
self.UpdateUI(-1)
def next_img(self, event):
if self.ImgManager.img_num != 0:
self.show_img_init()
self.ImgManager.add()
self.show_img()
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
self.SetStatusText_(["Next", "-1", "-1", "-1"])
def last_img(self, event):
if self.ImgManager.img_num != 0:
self.show_img_init()
self.ImgManager.subtract()
self.show_img()
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
self.SetStatusText_(["Last", "-1", "-1", "-1"])
def skip_to_n_img(self, event):
if self.ImgManager.img_num != 0:
self.show_img_init()
self.ImgManager.set_action_count(self.slider_img.GetValue())
self.show_img()
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
self.SetStatusText_(["Skip", "-1", "-1", "-1"])
def slider_value_change(self, event):
try:
value = int(self.slider_value.GetValue())
except:
self.slider_value.SetValue(str(self.ImgManager.action_count))
else:
if self.ImgManager.img_num != 0:
self.show_img_init()
self.ImgManager.set_action_count(value)
self.show_img()
self
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
self.SetStatusText_(["Skip", "-1", "-1", "-1"])
def save_img(self, event):
layout_params = self.set_img_layout()
if layout_params != False:
self.ImgManager.layout_params = layout_params
type_ = self.choice_output.GetSelection()
if self.auto_save_all.Value:
last_count_img = self.ImgManager.action_count
self.ImgManager.set_action_count(0)
if Path(self.out_path_str).is_dir():
continue_ = True
else:
continue_ = False
if continue_:
for i in range(self.ImgManager.max_action_num):
self.SetStatusText_(
["-1", "-1", "***"+str(self.ImgManager.name_list[self.ImgManager.action_count])+", saving img***", "-1"])
self.ImgManager.get_flist()
self.ImgManager.save_img(self.out_path_str, type_)
self.ImgManager.add()
self.ImgManager.set_action_count(last_count_img)
self.SetStatusText_(
["-1", "-1", "***Finish***", "-1"])
else:
self.SetStatusText_(
["-1", "-1", "***Error: First, need to select the output dir***", "-1"])
else:
try:
self.SetStatusText_(
["-1", "-1", "***"+str(self.ImgManager.name_list[self.ImgManager.action_count])+", saving img...***", "-1"])
except:
pass
flag = self.ImgManager.save_img(self.out_path_str, type_)
self.refresh(event)
if flag == 0:
self.SetStatusText_(
["Save", str(self.ImgManager.action_count), "Save success!", "-1"])
elif flag == 1:
self.SetStatusText_(
["-1", "-1", "***First, you need to select the output dir***", "-1"])
self.out_path(event)
self.SetStatusText_(
["-1", "-1", "", "-1"])
elif flag == 2:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count), "***Error: "+str(self.ImgManager.name_list[self.ImgManager.action_count]) + ", during stitching images***", "-1"])
elif flag == 3:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count), "***Error: "+str(self.ImgManager.name_list[self.ImgManager.action_count]) + ", the number of img in sub folders is different***", "-1"])
elif flag == 4:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count), "***Error: No magnification box, the magnified image can not be saved***", "-1"])
self.SetStatusText_(["Save", "-1", "-1", "-1"])
def refresh(self, event):
if self.ImgManager.img_num != 0:
self.show_img_init()
self.show_img()
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
self.SetStatusText_(["Refresh", "-1", "-1", "-1"])
def one_dir_mul_dir_auto(self, event):
self.SetStatusText_(["Input", "", "", "-1"])
dlg = wx.DirDialog(None, "Parallel auto choose input dir", "",
wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
self.ImgManager.init(
dlg.GetPath(), 0, self.parallel_to_sequential.Value)
self.show_img_init()
self.ImgManager.set_action_count(0)
self.show_img()
self.choice_input_mode.SetSelection(1)
self.SetStatusText_(["Input", "-1", "-1", "-1"])
def one_dir_mul_dir_manual(self, event):
self.SetStatusText_(["Input", "", "", "-1"])
try:
if self.ImgManager.type == 1:
input_path = self.ImgManager.input_path
else:
input_path = None
except:
input_path = None
self.UpdateUI(1, input_path, self.parallel_to_sequential.Value)
self.choice_input_mode.SetSelection(2)
self.SetStatusText_(["Input", "-1", "-1", "-1"])
def one_dir_mul_img(self, event):
self.SetStatusText_(
["Sequential choose input dir", "", "", "-1"])
dlg = wx.DirDialog(None, "Choose input dir", "",
wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
self.ImgManager.init(dlg.GetPath(), 2)
self.show_img_init()
self.ImgManager.set_action_count(0)
self.show_img()
self.choice_input_mode.SetSelection(0)
self.SetStatusText_(
["Sequential choose input dir", "-1", "-1", "-1"])
def onefilelist(self, event):
self.SetStatusText_(["Choose the File List", "", "", "-1"])
wildcard = "List file (*.txt; *.csv)|*.txt;*.csv|" \
"All files (*.*)|*.*"
dlg = wx.FileDialog(None, "choose the Images List", "", "",
wildcard, wx.FD_DEFAULT_STYLE | wx.FD_FILE_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
self.ImgManager.init(dlg.GetPath(), 3)
self.show_img_init()
self.ImgManager.set_action_count(0)
self.show_img()
self.choice_input_mode.SetSelection(3)
self.SetStatusText_(["Choose the File List", "-1", "-1", "-1"])
def input_flist_parallel_manual(self, event):
wildcard = "List file (*.txt;)|*.txt;|" \
"All files (*.*)|*.*"
dlg = wx.FileDialog(None, "choose the Images List", "", "",
wildcard, wx.FD_DEFAULT_STYLE | wx.FD_FILE_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
with open(dlg.GetPath(), "r") as f:
input_path = f.read().split('\n')
self.ImgManager.init(
input_path[0:-1], 1, self.parallel_to_sequential.Value)
self.show_img_init()
self.ImgManager.set_action_count(0)
self.show_img()
self.choice_input_mode.SetSelection(2)
def save_flist_parallel_manual(self, event):
if self.out_path_str == "":
self.SetStatusText_(
["-1", "-1", "***Error: First, need to select the output dir***", "-1"])
else:
try:
np.savetxt(Path(self.out_path_str)/"input_flist_parallel_manual.txt",
self.ImgManager.input_path, fmt='%s')
except:
self.SetStatusText_(
["-1", "-1", "***Error: First, need to select parallel manual***", "-1"])
else:
self.SetStatusText_(
["-1", "-1", "Save" + str(Path(self.out_path_str)/"input_flist_parallel_manual.txt")+" success!", "-1"])
def out_path(self, event):
if len(self.img_name) != 0:
self.SetStatusText_(
["Choose out dir", str(self.ImgManager.action_count), self.img_name[self.ImgManager.action_count], "-1"])
else:
self.SetStatusText_(["Choose out dir", "-1", "-1", "-1"])
dlg = wx.DirDialog(None, "Choose out dir", "",
wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
self.out_path_str = dlg.GetPath()
self.m_statusBar1.SetStatusText(self.out_path_str, 3)
def colour_change(self, event):
c = self.colourPicker_gap.GetColour()
self.ImgManager.gap_color = (
c.red, c.green, c.blue, self.ImgManager.gap_alpha)
def background_alpha(self, event):
c = self.colourPicker_gap.GetColour()
self.ImgManager.gap_alpha = self.background_slider.GetValue()
self.ImgManager.gap_color = (
c.red, c.green, c.blue, self.ImgManager.gap_alpha)
def foreground_alpha(self, event):
self.ImgManager.img_alpha = self.foreground_slider.GetValue()
def delete_box(self, event):
if self.select_img_box.Value:
if self.box_id != -1:
self.xy_magnifier.pop(self.box_id)
self.refresh(event)
self.SetStatusText_(
["delete "+str(self.box_id)+"-th box", "-1", "-1", "-1"])
else:
self.xy_magnifier = []
self.refresh(event)
self.SetStatusText_(["delete all box", "-1", "-1", "-1"])
def up_img(self, event):
speed = self.get_speed(name="pixel")
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
x, y = self.get_center_box(box_point)
x = x+0
y = y-speed
self.xy_magnifier[self.box_id][0:4] = self.move_box_point(
x, y, show_scale)
self.refresh(event)
else:
size = self.scrolledWindow_img.GetSize()
self.position[0] = int(
self.scrolledWindow_img.GetScrollPos(wx.HORIZONTAL)/self.Uint[0])
self.position[1] = int(
self.scrolledWindow_img.GetScrollPos(wx.VERTICAL)/self.Uint[1])
if self.position[1] > 0:
self.position[1] -= speed
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], self.position[1]*self.Uint[1])
self.SetStatusText_(["Up", "-1", "-1", "-1"])
def down_img(self, event):
speed = self.get_speed(name="pixel")
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
x, y = self.get_center_box(box_point)
x = x+0
y = y+speed
self.xy_magnifier[self.box_id][0:4] = self.move_box_point(
x, y, show_scale)
self.refresh(event)
else:
size = self.scrolledWindow_img.GetSize()
self.position[0] = int(
self.scrolledWindow_img.GetScrollPos(wx.HORIZONTAL)/self.Uint[0])
self.position[1] = int(
self.scrolledWindow_img.GetScrollPos(wx.VERTICAL)/self.Uint[1])
if (self.position[1]-1)*self.Uint[1] < size[1]:
self.position[1] += speed
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], self.position[1]*self.Uint[1])
else:
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], size[1])
self.SetStatusText_(["Down", "-1", "-1", "-1"])
def right_img(self, event):
speed = self.get_speed(name="pixel")
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
x, y = self.get_center_box(box_point)
x = x+speed
y = y+0
self.xy_magnifier[self.box_id][0:4] = self.move_box_point(
x, y, show_scale)
self.refresh(event)
else:
size = self.scrolledWindow_img.GetSize()
self.position[0] = int(
self.scrolledWindow_img.GetScrollPos(wx.HORIZONTAL)/self.Uint[0])
self.position[1] = int(
self.scrolledWindow_img.GetScrollPos(wx.VERTICAL)/self.Uint[1])
if (self.position[0]-1)*self.Uint[0] < size[0]:
self.position[0] += speed
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], self.position[1]*self.Uint[1])
else:
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], size[0])
self.SetStatusText_(["Right", "-1", "-1", "-1"])
def left_img(self, event):
speed = self.get_speed(name="pixel")
if self.select_img_box.Value:
if self.box_id != -1:
box_point = self.xy_magnifier[self.box_id][0:4]
show_scale = self.xy_magnifier[self.box_id][4:6]
x, y = self.get_center_box(box_point)
x = x-speed
y = y+0
self.xy_magnifier[self.box_id][0:4] = self.move_box_point(
x, y, show_scale)
self.refresh(event)
else:
size = self.scrolledWindow_img.GetSize()
self.position[0] = int(
self.scrolledWindow_img.GetScrollPos(wx.HORIZONTAL)/self.Uint[0])
self.position[1] = int(
self.scrolledWindow_img.GetScrollPos(wx.VERTICAL)/self.Uint[1])
if self.position[0] > 0:
self.position[0] -= speed
self.scrolledWindow_img.Scroll(
self.position[0]*self.Uint[0], self.position[1]*self.Uint[1])
self.SetStatusText_(["Left", "-1", "-1", "-1"])
def SetStatusText_(self, texts):
for i in range(self.Status_number):
if texts[i] != '-1':
self.m_statusBar1.SetStatusText(texts[i], i)
def img_left_click(self, event):
if self.magnifier.Value:
x_0, y_0 = event.GetPosition()
self.x_0 = x_0
self.y_0 = y_0
self.x = x_0
self.y = y_0
if self.select_img_box.Value:
# select box
x, y = event.GetPosition()
id = self.get_img_id_from_point([x, y])
xy_grid = self.ImgManager.xy_grid[id]
x = x-xy_grid[0]
y = y-xy_grid[1]
x_y_array = []
for i in range(len(self.ImgManager.crop_points)):
x_y_array.append(self.get_center_box(
self.ImgManager.crop_points[i][0:4]))
x_y_array = np.array(x_y_array)
dist = (x_y_array[:, 0]-x)**2+(x_y_array[:, 1]-y)**2
self.box_id = np.array(dist).argmin()
str_ = str(self.box_id)
self.SetStatusText_(["Select "+str_+"-th box", "-1", "-1", "-1"])
self.start_flag = 0
else:
# magnifier
if self.magnifier.Value:
self.start_flag = 1
else:
self.start_flag = 0
if self.magnifier.Value:
self.SetStatusText_(["Magnifier", "-1", "-1", "-1"])
# rotation
if self.rotation.Value:
x, y = event.GetPosition()
self.ImgManager.rotate(
self.get_img_id_from_point([x, y], img=True))
self.refresh(event)
self.SetStatusText_(["Rotate", "-1", "-1", "-1"])
# flip
if self.flip.Value:
x, y = event.GetPosition()
self.ImgManager.flip(self.get_img_id_from_point(
[x, y], img=True), FLIP_TOP_BOTTOM=self.checkBox_orientation.Value)
self.refresh(event)
self.SetStatusText_(["Flip", "-1", "-1", "-1"])
# focus img
if self.indextablegui or self.aboutgui:
pass
else:
self.img_panel.Children[0].SetFocus()
# show dir_id
x, y = event.GetPosition()
id = self.get_img_id_from_point([x, y])
second_txt = self.m_statusBar1.GetStatusText(1)
second_txt = second_txt.split("/")[0]
self.m_statusBar1.SetStatusText(second_txt+"/"+str(id)+"-th dir", 1)
def img_left_dclick(self, event):
if self.select_img_box.Value:
pass
else:
self.start_flag = 0
self.xy_magnifier = []
self.color_list = []
def img_left_move(self, event):
# https://stackoverflow.com/questions/57342753/how-to-select-a-rectangle-of-the-screen-to-capture-by-dragging-mouse-on-transpar
if self.magnifier.Value != False and self.start_flag == 1:
x, y = event.GetPosition()
id = self.get_img_id_from_point([self.x_0, self.y_0])
xy_grid = self.ImgManager.xy_grid[id]
xy_limit = np.array(xy_grid) + \
np.array(self.ImgManager.img_resolution_show)
if self.x_0 < xy_limit[0] and self.y_0 < xy_limit[1]:
if x < xy_limit[0] and y < xy_limit[1]:
self.x = x
self.y = y
elif x > xy_limit[0] and y > xy_limit[1]:
self.x = xy_limit[0]
self.y = xy_limit[1]
elif x > xy_limit[0]:
self.x = xy_limit[0]
self.y = y
elif y > xy_limit[1]:
self.x = x
self.y = xy_limit[1]
# show mouse position
x, y = event.GetPosition()
id = self.get_img_id_from_point([x, y])
xy_grid = self.ImgManager.xy_grid[id]
RGBA = self.ImgManager.img.getpixel((int(x), int(y)))
x = x-xy_grid[0]
y = y-xy_grid[1]
self.m_statusBar1.SetStatusText(str(x)+","+str(y)+"/"+str(RGBA), 0)
def img_left_release(self, event):
if self.magnifier.Value != False:
self.start_flag = 0
id = self.get_img_id_from_point([self.x_0, self.y_0])
xy_grid = self.ImgManager.xy_grid[id]
x = self.x-xy_grid[0]
y = self.y-xy_grid[1]
x_0 = self.x_0 - xy_grid[0]
y_0 = self.y_0 - xy_grid[1]
width = np.abs(x-x_0)
height = np.abs(y-y_0)
if width > 5 and height > 5:
self.xy_magnifier = []
self.color_list.append(self.colourPicker_draw.GetColour())
show_scale = self.show_scale.GetLineText(0).split(',')
show_scale = [float(x) for x in show_scale]
points = self.ImgManager.ImgF.sort_box_point(
[x_0, y_0, x, y], show_scale, self.ImgManager.img_resolution_origin, first_point=True)
self.xy_magnifier.append(
points+show_scale+[self.ImgManager.title_setting[2] and self.ImgManager.title_setting[1]])
self.refresh(event)
def img_right_click(self, event):
x, y = event.GetPosition()
id = self.get_img_id_from_point([x, y])
xy_grid = self.ImgManager.xy_grid[id]
x = x-xy_grid[0]
y = y-xy_grid[1]
if self.select_img_box.Value:
# move box
if self.box_id != -1:
show_scale = self.show_scale.GetLineText(0).split(',')
show_scale = [float(x) for x in show_scale]
points = self.move_box_point(x, y, show_scale)
self.xy_magnifier[self.box_id] = points+show_scale+[
self.ImgManager.title_setting[2] and self.ImgManager.title_setting[1]]
self.refresh(event)
else:
# new box
if self.magnifier.Value:
self.color_list.append(self.colourPicker_draw.GetColour())
try:
show_scale = self.show_scale.GetLineText(0).split(',')
show_scale = [float(x) for x in show_scale]
points = self.move_box_point(x, y, show_scale)
self.xy_magnifier.append(
points+show_scale+[self.ImgManager.title_setting[2] and self.ImgManager.title_setting[1]])
except:
self.SetStatusText_(
["-1", "Drawing a box need click left mouse button!", "-1", "-1"])
self.refresh(event)
self.SetStatusText_(["Magnifier", "-1", "-1", "-1"])
else:
self.refresh(event)
def move_box_point(self, x, y, show_scale):
x_0, y_0, x_1, y_1 = self.xy_magnifier[0][0:4]
show_scale_old = self.xy_magnifier[0][4:6]
scale = [show_scale[0]/show_scale_old[0],
show_scale[1]/show_scale_old[1]]
x_0 = int(x_0*scale[0])
x_1 = int(x_1*scale[0])
y_0 = int(y_0*scale[1])
y_1 = int(y_1*scale[1])
x_center_old, y_center_old = self.get_center_box(
[x_0, y_0, x_1, y_1])
delta_x = x-x_center_old
delta_y = y-y_center_old
return self.ImgManager.ImgF.sort_box_point([x_0+delta_x, y_0+delta_y, x_1+delta_x, y_1+delta_y], self.ImgManager.img_resolution_origin, show_scale)
def get_center_box(self, box, more=False):
x_0, y_0, x_1, y_1 = box
width = abs(x_0-x_1)
height = abs(y_0-y_1)
x_center_old = x_0+int((width)/2)
y_center_old = y_0+int((height)/2)
if more:
return [x_center_old, y_center_old, width, height]
else:
return [x_center_old, y_center_old]
def img_wheel(self, event):
# https://wxpython.org/Phoenix/docs/html/wx.MouseEvent.html
# zoom
i_cur = 0
status_toggle = [self.magnifier, self.rotation, self.flip]
if status_toggle[i_cur].Value and self.key_status["ctrl"] == 1:
if event.GetWheelDelta() >= 120:
speed = self.get_speed(name="scale")
self.adjust_show_scale_proportion() # adjust show_scale_proportion
# set show_scale
if event.GetWheelRotation() > 0:
self.show_scale_proportion = self.show_scale_proportion+speed
else:
self.show_scale_proportion = self.show_scale_proportion-speed
if self.show_scale_proportion > 0:
show_scale = [1*(1+self.show_scale_proportion),
1*(1+self.show_scale_proportion)]
elif self.show_scale_proportion < 0:
show_scale = [1/(1-self.show_scale_proportion),
1/(1-self.show_scale_proportion)]
else:
show_scale = [1, 1]
self.show_scale.Value = str(
round(show_scale[0], 2))+","+str(round(show_scale[1], 2))
self.refresh(event)
else:
pass
else:
pass
# move
if self.key_status["ctrl"] == 0 and event.GetWheelDelta() >= 120:
if event.WheelAxis == 0:
if event.GetWheelRotation() > 0:
self.up_img(event)
else:
self.down_img(event)
else:
if event.GetWheelRotation() > 0:
self.right_img(event)
else:
self.left_img(event)
def adjust_show_scale_proportion(self):
# check "cur_scale", and adjust "self.show_scale_proportion"
cur_scale = self.show_scale.GetLineText(0).split(',')
cur_scale = [float(x) for x in cur_scale]
if self.show_scale_proportion > 0:
if cur_scale[0] == round(1*(1+self.show_scale_proportion), 2):
pass
else:
if cur_scale[0] > 1:
self.show_scale_proportion = cur_scale[0]-1
elif cur_scale[0] < 1 and cur_scale[0] > 0:
self.show_scale_proportion = 1-1/cur_scale[0]
elif cur_scale[0] == 1:
self.show_scale_proportion = 0
else:
pass
elif self.show_scale_proportion < 0:
if cur_scale[0] == round(1/(1-self.show_scale_proportion), 2):
pass
else:
if cur_scale[0] > 1:
self.show_scale_proportion = cur_scale[0]-1
elif cur_scale[0] < 1 and cur_scale[0] > 0:
self.show_scale_proportion = 1-1/cur_scale[0]
elif cur_scale[0] == 1:
self.show_scale_proportion = 0
else:
pass
else:
self.show_scale_proportion = 0
def key_down_detect(self, event):
if event.GetKeyCode() == wx.WXK_CONTROL:
if self.key_status["ctrl"] == 0:
self.key_status["ctrl"] = 1
elif event.GetKeyCode() == wx.WXK_SHIFT:
if self.key_status["shift"] == 0:
self.key_status["shift"] = 1
elif self.key_status["shift"] == 1:
self.key_status["shift"] = 0
def key_up_detect(self, event):
if event.GetKeyCode() == wx.WXK_CONTROL:
if self.key_status["ctrl"] == 1:
self.key_status["ctrl"] = 0
elif event.GetKeyCode() == wx.WXK_SHIFT:
pass
def get_speed(self, name="pixel"):
if name == "pixel":
if self.key_status["shift"] == 1:
speed = 5
else:
speed = 1
elif name == "scale":
if self.key_status["shift"] == 1:
speed = 0.5
else:
speed = 0.1
else:
speed = None
return speed
def magnifier_fc(self, event):
self.start_flag = 0
i_cur = 0
status_toggle = [self.magnifier, self.rotation, self.flip]
if status_toggle[i_cur].Value:
self.SetCursor(wx.Cursor(wx.CURSOR_CROSS))
for i in range(len(status_toggle)):
if i != i_cur and status_toggle[i].Value:
status_toggle[i].Value = False
self.SetStatusText_(["Magnifier", "-1", "-1", "-1"])
else:
self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
self.Refresh()
def rotation_fc(self, event):
i_cur = 1
status_toggle = [self.magnifier, self.rotation, self.flip]
if status_toggle[i_cur].Value:
self.SetCursor(wx.Cursor(wx.CURSOR_POINT_RIGHT))
for i in range(len(status_toggle)):
if i != i_cur and status_toggle[i].Value:
status_toggle[i].Value = False
self.SetStatusText_(["Rotate", "-1", "-1", "-1"])
else:
self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
self.Refresh()
def flip_fc(self, event):
i_cur = 2
status_toggle = [self.magnifier, self.rotation, self.flip]
if status_toggle[i_cur].Value:
flip_cursor_path = Path(get_resource_path(str(Path("img"))))
flip_cursor_path = str(flip_cursor_path/"flip_cursor.png")
self.SetCursor(
wx.Cursor((wx.Image(flip_cursor_path, wx.BITMAP_TYPE_PNG))))
for i in range(len(status_toggle)):
if i != i_cur and status_toggle[i].Value:
status_toggle[i].Value = False
self.SetStatusText_(["Flip", "-1", "-1", "-1"])
else:
self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
self.Refresh()
def show_img_init(self):
layout_params = self.set_img_layout()
if layout_params != False:
# setting
self.ImgManager.layout_params = layout_params
if self.ImgManager.type == 0 or self.ImgManager.type == 1:
if self.parallel_to_sequential.Value:
self.ImgManager.set_count_per_action(
layout_params[0]*layout_params[1]*layout_params[2])
else:
if self.parallel_sequential.Value:
self.ImgManager.set_count_per_action(layout_params[1])
else:
self.ImgManager.set_count_per_action(1)
elif self.ImgManager.type == 2 or self.ImgManager.type == 3:
self.ImgManager.set_count_per_action(
layout_params[0]*layout_params[1]*layout_params[2])
def set_img_layout(self):
try:
num_per_img = int(self.num_per_img.GetLineText(0))
if num_per_img == -1:
row_col = self.ImgManager.layout_advice()
self.img_num_per_row.SetValue(str(row_col[1]))
self.img_num_per_column.SetValue(str(row_col[0]))
num_per_img = 1
img_num_per_row = int(self.img_num_per_row.GetLineText(0))
img_num_per_column = int(self.img_num_per_column.GetLineText(0))
gap = self.gap.GetLineText(0).split(',')
gap = [int(x) for x in gap]
show_scale = self.show_scale.GetLineText(0).split(',')
show_scale = [float(x) for x in show_scale]
output_scale = self.output_scale.GetLineText(0).split(',')
output_scale = [float(x) for x in output_scale]
img_resolution = self.img_resolution.GetLineText(0).split(',')
img_resolution = [int(x) for x in img_resolution]
magnifier_scale = self.magnifier_scale.GetLineText(0).split(',')
magnifier_scale = [float(x) for x in magnifier_scale]
if self.checkBox_auto_draw_color.Value:
# 10 colors built into the software
color_list = [
wx.Colour(217, 26, 42, 85/100*255),
wx.Colour(147, 81, 166, 65/100*255),
wx.Colour(85, 166, 73, 65/100*255),
wx.Colour(242, 229, 48, 95/100*255),
wx.Colour(242, 116, 5, 95/100*255),
wx.Colour(242, 201, 224, 95/100*255),
wx.Colour(36, 132, 191, 75/100*255),
wx.Colour(65, 166, 90, 65/100*255),
wx.Colour(214, 242, 206, 95/100*255),
wx.Colour(242, 163, 94, 95/100*255)]
num_box = len(self.xy_magnifier)
if num_box <= len(color_list):
self.color_list = color_list[0:num_box]
else:
self.color_list = color_list + \
color_list[0:num_box-len(color_list)]
color = self.color_list
line_width = self.line_width.GetLineText(0).split(',')
line_width = [int(x) for x in line_width]
title_setting = [self.title_auto.Value, # 0
self.title_show.Value, # 1
self.title_down_up.Value, # 2
self.title_show_parent.Value, # 3
self.title_show_prefix.Value, # 4
self.title_show_name.Value, # 5
self.title_show_suffix.Value, # 6
self.title_font.GetSelection(), # 7
self.title_font_size.Value, # 8
self.font_paths] # 9
if title_setting[0]:
if self.ImgManager.type == 0 or self.ImgManager.type == 1:
# one_dir_mul_dir_auto / one_dir_mul_dir_manual
if self.parallel_sequential.Value or self.parallel_to_sequential.Value:
title_setting[2:7] = [False, True, True, True, False]
else:
title_setting[2:7] = [False, True, True, False, False]
elif self.ImgManager.type == 2:
# one_dir_mul_img
title_setting[2:7] = [False, False, True, True, False]
elif self.ImgManager.type == 3:
# read file list from a list file
title_setting[2:7] = [False, True, True, True, False]
except:
self.SetStatusText_(
["-1", "-1", "***Error: setting***", "-1"])
return False
else:
return [img_num_per_row, # 0
num_per_img, # 1
img_num_per_column, # 2
gap, # 3
show_scale, # 4
output_scale, # 5
img_resolution, # 6
1 if self.magnifier.Value else 0, # 7
magnifier_scale, # 8
color, # 9
line_width, # 10
self.move_file.Value, # 11
self.keep_magnifer_size.Value, # 12
self.image_interp.GetSelection(), # 13
self.show_box.Value, # 14
self.show_box_in_crop.Value, # 15
self.show_original.Value, # 16
title_setting, # 17
self.show_crop.Value, # 18
self.parallel_to_sequential.Value, # 19
self.one_img.Value, # 20
self.box_position.GetSelection(), # 21
self.parallel_sequential.Value, # 22
self.auto_save_all.Value, # 23
# add new in this line
self.checkBox_orientation.Value]
def show_img(self):
# check layout_params change
try:
if self.layout_params_old[0:3] != self.ImgManager.layout_params[0:3] or (self.layout_params_old[19] != self.ImgManager.layout_params[19]):
action_count = self.ImgManager.action_count
if self.ImgManager.type == 0 or self.ImgManager.type == 1:
parallel_to_sequential = self.parallel_to_sequential.Value
else:
parallel_to_sequential = False
self.ImgManager.init(
self.ImgManager.input_path, self.ImgManager.type, parallel_to_sequential)
self.show_img_init()
self.ImgManager.set_action_count(action_count)
if self.index_table_gui:
self.index_table_gui.show_id_table(
self.ImgManager.name_list, self.ImgManager.layout_params)
except:
pass
self.layout_params_old = self.ImgManager.layout_params
self.slider_img.SetValue(self.ImgManager.action_count)
self.slider_value.SetValue(str(self.ImgManager.action_count))
self.slider_value_max.SetLabel(
str(self.ImgManager.max_action_num-1))
# Destroy the window to avoid memory leaks
try:
self.img_last.Destroy()
except:
pass
# show img
if self.ImgManager.max_action_num > 0:
self.slider_img.SetMax(self.ImgManager.max_action_num-1)
self.ImgManager.get_flist()
flag = self.ImgManager.stitch_images(
0, copy.deepcopy(self.xy_magnifier))
if flag == 0:
bmp = self.ImgManager.img
self.img_size = bmp.size
bmp = self.ImgManager.ImgF.PIL2wx(bmp)
self.img_panel.SetSize(
wx.Size(self.img_size[0]+100, self.img_size[1]+100))
self.img_last = wx.StaticBitmap(parent=self.img_panel,
bitmap=bmp)
self.img_panel.Children[0].SetFocus()
self.img_panel.Children[0].Bind(
wx.EVT_LEFT_DOWN, self.img_left_click)
self.img_panel.Children[0].Bind(
wx.EVT_LEFT_DCLICK, self.img_left_dclick)
self.img_panel.Children[0].Bind(
wx.EVT_MOTION, self.img_left_move)
self.img_panel.Children[0].Bind(
wx.EVT_LEFT_UP, self.img_left_release)
self.img_panel.Children[0].Bind(
wx.EVT_RIGHT_DOWN, self.img_right_click)
self.img_panel.Children[0].Bind(
wx.EVT_MOUSEWHEEL, self.img_wheel)
self.img_panel.Children[0].Bind(
wx.EVT_KEY_DOWN, self.key_down_detect)
self.img_panel.Children[0].Bind(
wx.EVT_KEY_UP, self.key_up_detect)
# status
if self.ImgManager.type == 2 or ((self.ImgManager.type == 0 or self.ImgManager.type == 1) and self.parallel_sequential.Value):
try:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count)+"/"+str(self.ImgManager.get_dir_num())+" dir", str(self.ImgManager.img_resolution[0])+"x"+str(self.ImgManager.img_resolution[1])+" pixels / "+str(self.ImgManager.name_list[self.ImgManager.img_count])+"-"+str(self.ImgManager.name_list[self.ImgManager.img_count+self.ImgManager.count_per_action-1]), "-1"])
except:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count)+"/"+str(self.ImgManager.get_dir_num())+" dir", str(self.ImgManager.img_resolution[0])+"x"+str(self.ImgManager.img_resolution[1])+" pixels / "+str(self.ImgManager.name_list[self.ImgManager.img_count])+"-"+str(self.ImgManager.name_list[self.ImgManager.img_num-1]), "-1"])
else:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count)+"/"+str(self.ImgManager.get_dir_num())+" dir", str(self.ImgManager.img_resolution[0])+"x"+str(self.ImgManager.img_resolution[1])+" pixels / "+self.ImgManager.get_stitch_name(), "-1"])
if flag == 1:
self.SetStatusText_(
["-1", str(self.ImgManager.action_count)+"/"+str(self.ImgManager.get_dir_num())+" dir", "***Error: "+str(self.ImgManager.name_list[self.ImgManager.action_count]) + ", during stitching images***", "-1"])
if flag == 2:
self.SetStatusText_(
["-1", "-1", "No image is displayed! Check Show orignal/Show 🔍️/Show title.", "-1"])
else:
self.SetStatusText_(
["-1", "-1", "***Error: no image in this dir! Maybe you can choose parallel mode!***", "-1"])
self.auto_layout()
self.SetStatusText_(["Stitch", "-1", "-1", "-1"])
def auto_layout(self, frame_resize=False):
# Auto Layout
# Get current window size
# self.displaySize = wx.Size(wx.DisplaySize()) # get main window size
# Get current window id
displays = (wx.Display(i) for i in range(wx.Display.GetCount()))
displays_list = [display for display in displays]
sizes = [display.GetGeometry().GetSize() for display in displays_list]
screen_id = wx.Display.GetFromWindow(self)
self.displaySize = sizes[screen_id]
if self.hidden_flag == 1:
offset_hight_img_show = 50
else:
offset_hight_img_show = 0
if self.auto_layout_check.Value and (not frame_resize):
if self.img_size[0] < self.width:
if self.img_size[0]+self.width_setting+40 < self.width:
w = self.width
else:
w = self.img_size[0]+self.width_setting+40
elif self.img_size[0]+self.width_setting+40 > self.displaySize[0]:
w = self.displaySize[0]
else:
w = self.img_size[0]+self.width_setting+40
if self.img_size[1] < self.height:
if self.img_size[1]+200 < self.height:
h = self.height
else:
h = self.img_size[1]+200
if self.hidden_flag == 1:
h=h-50
elif self.img_size[1]+200 > self.displaySize[1]:
h = self.displaySize[1]
else:
h = self.img_size[1]+200
if self.hidden_flag == 1:
h=h-50
self.Size = wx.Size((w, h))
if self.hidden_flag == 1:
self.m_splitter1.SashPosition = self.Size[0]
self.init_min_size()
self.scrolledWindow_set.SetMinSize(
wx.Size((self.width_setting, -1)))
self.scrolledWindow_img.SetMinSize(
wx.Size((self.Size[0]-self.width_setting, self.Size[1]-150+offset_hight_img_show)))
# issue: You need to change the window size, then the scrollbar starts to display.
self.scrolledWindow_img.FitInside()
self.scrolledWindow_set.FitInside()
self.Layout()
self.Refresh()
def init_min_size(self):
self.scrolledWindow_set.SetMinSize(
wx.Size((50, -1)))
self.scrolledWindow_img.SetMinSize(
wx.Size((50, self.Size[1]-150)))
def split_sash_pos_changing(self, event):
self.init_min_size()
self.split_changing = True
def split_sash_pos_changed(self, event):
self.SashPosition = self.m_splitter1.SashPosition
if self.split_changing:
self.width_setting = self.Size[0]-self.SashPosition
self.scrolledWindow_set.SetMinSize(
wx.Size((self.width_setting, -1)))
self.scrolledWindow_img.SetMinSize(
wx.Size((self.Size[0] - self.width_setting, self.Size[1]-150)))
self.split_changing = False
# print(self.SashPosition)
def about_gui(self, event, update=False, new_version=None):
self.aboutgui = About(self, self.version,
update=update, new_version=new_version)
self.aboutgui.Show(True)
def index_table_gui(self, event):
if self.ImgManager.img_num != 0:
if self.ImgManager.dataset_mode and self.out_path_str == "":
self.SetStatusText_(
["-1", "-1", "***Error: First, need to select the output dir***", "-1"])
else:
if self.ImgManager.dataset_mode:
self.SetStatusText_(
["-1", "-1", "index_table.txt saving...", "-1"])
if self.ImgManager.type == 3:
self.indextablegui = IndexTable(
None, self.ImgManager.path_list, self.ImgManager.layout_params, self.ImgManager.dataset_mode, self.out_path_str, self.ImgManager.type, self.parallel_sequential.Value)
else:
self.indextablegui = IndexTable(
None, self.ImgManager.name_list, self.ImgManager.layout_params, self.ImgManager.dataset_mode, self.out_path_str, self.ImgManager.type, self.parallel_sequential.Value)
if self.ImgManager.dataset_mode:
self.SetStatusText_(
["-1", "-1", "index_table.txt save in "+self.out_path_str, "-1"])
else:
self.SetStatusText_(
["-1", "", "***Error: First, need to select the input dir***", "-1"])
def create_ImgManager(self):
self.ImgManager = ImgManager()
self.colour_change([])
return self.ImgManager
def change_img_stitch_mode(self, event):
self.ImgManager.img_stitch_mode = self.choice_normalized_size.GetSelection()
def get_img_id_from_point(self, xy, img=False):
# get img_id from grid points
xy_grid = np.array(self.ImgManager.xy_grid)
xy_cur = np.array([xy])
xy_cur = np.repeat(xy_cur, xy_grid.shape[0], axis=0)
res_ = xy_cur - xy_grid
id_list = []
for i in range(xy_grid.shape[0]):
if res_[i][0] >= 0 and res_[i][1] >= 0:
id_list.append(i)
else:
id_list.append(0)
if img:
return self.ImgManager.xy_grids_id_list[max(id_list)]
else:
return max(id_list)
def title_down_up_fc(self, event):
if self.title_down_up.Value:
self.title_down_up.SetLabel('Up ')
else:
self.title_down_up.SetLabel('Down')
def parallel_sequential_fc(self, event):
if self.parallel_sequential.Value:
self.parallel_to_sequential.Value = False
def parallel_to_sequential_fc(self, event):
if self.parallel_to_sequential.Value:
self.parallel_sequential.Value = False
def title_auto_fc(self, event):
titles = [self.title_down_up, self.title_show_parent,
self.title_show_name, self.title_show_suffix, self.title_show_prefix]
if self.title_auto.Value:
for title in titles:
title.Enabled = False
else:
for title in titles:
title.Enabled = True
# def show_scale_change(self, event):
# self.show_scale_proportion = 0
# self.refresh(event)
# self.show_scale = wx.TextCtrl( self.scrolledWindow_set, wx.ID_ANY, u"1,1", wx.DefaultPosition, wx.Size( 60,-1 ), style=wx.TE_PROCESS_ENTER)
# wSizer6.Add( self.show_scale, 0, wx.ALL, 5 )
def select_img_box_func(self, event):
if self.select_img_box.Value:
self.box_id = -1
event.Skip()
def draw_color_change(self, event):
if self.select_img_box.Value:
if self.box_id != -1:
if self.checkBox_auto_draw_color.Value:
self.checkBox_auto_draw_color.Value = False
self.color_list[self.box_id] = self.colourPicker_draw.GetColour()
self.refresh(event)
event.Skip()
def hidden(self, event):
if self.hidden_flag == 0:
self.Sizer.Hide(self.m_panel1)
self.scrolledWindow_set.Sizer.Hide(self.m_panel4)
self.width_setting_ = self.width_setting
self.width_setting = 0
self.hidden_flag = 1
else:
self.Sizer.Show(self.m_panel1)
self.scrolledWindow_set.Sizer.Show(self.m_panel4)
self.width_setting = self.width_setting_
self.hidden_flag = 0
# issue: You need to change the window size, then the scrollbar starts to display.
self.scrolledWindow_set.FitInside()
self.auto_layout()

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/nachifur-MulimgViewer.git
git@api.gitlife.ru:oschina-mirror/nachifur-MulimgViewer.git
oschina-mirror
nachifur-MulimgViewer
nachifur-MulimgViewer
master