Added Export function
Removed useless input :(
This commit is contained in:
parent
4331f3b090
commit
dcd4411fbd
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"path": "",
|
"path": "",
|
||||||
|
"out": "",
|
||||||
"size": 750
|
"size": 750
|
||||||
}
|
}
|
@ -192,7 +192,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="ttk.Button" id="button3">
|
<object class="ttk.Button" id="button3">
|
||||||
<property name="text" translatable="yes">Useless button</property>
|
<property name="text" translatable="yes">Export PNG</property>
|
||||||
<bind sequence="<ButtonPress>" handler="apply" add="" />
|
<bind sequence="<ButtonPress>" handler="apply" add="" />
|
||||||
<layout manager="grid">
|
<layout manager="grid">
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
@ -215,7 +215,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="ttk.Label" id="label1">
|
<object class="ttk.Label" id="label1">
|
||||||
<property name="text" translatable="yes">Useless imput</property>
|
<property name="text" translatable="yes">Export Image by ID</property>
|
||||||
<layout manager="grid">
|
<layout manager="grid">
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="columnspan">2</property>
|
<property name="columnspan">2</property>
|
||||||
@ -228,8 +228,10 @@
|
|||||||
<property name="height">15</property>
|
<property name="height">15</property>
|
||||||
<property name="pady">0</property>
|
<property name="pady">0</property>
|
||||||
<property name="selectborderwidth">4</property>
|
<property name="selectborderwidth">4</property>
|
||||||
|
<property name="setgrid">false</property>
|
||||||
<property name="state">disabled</property>
|
<property name="state">disabled</property>
|
||||||
<property name="text" translatable="yes">Image metadata should appear here</property>
|
<property name="takefocus">true</property>
|
||||||
|
<property name="text" translatable="yes">Image IDs should appear here</property>
|
||||||
<property name="width">25</property>
|
<property name="width">25</property>
|
||||||
<property name="wrap">word</property>
|
<property name="wrap">word</property>
|
||||||
<layout manager="grid">
|
<layout manager="grid">
|
||||||
|
19
src/suite.py
19
src/suite.py
@ -10,6 +10,8 @@ import time
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import json
|
import json
|
||||||
from helpers.statistics import imgStats
|
from helpers.statistics import imgStats
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
## UI config load
|
## UI config load
|
||||||
PROJECT_PATH = pathlib.Path(__file__).parent
|
PROJECT_PATH = pathlib.Path(__file__).parent
|
||||||
@ -97,11 +99,25 @@ class MainApp:
|
|||||||
'''
|
'''
|
||||||
Export current dataset
|
Export current dataset
|
||||||
'''
|
'''
|
||||||
|
# Get export settings
|
||||||
img_arr = self.tk_imgs
|
img_arr = self.tk_imgs
|
||||||
img_id = self.export_id.get()
|
img_id = self.export_id.get()
|
||||||
|
path = config_json["out"]
|
||||||
|
|
||||||
if (img_id >= 0 and img_id < len(img_arr)):
|
if (img_id >= 0 and img_id < len(img_arr)):
|
||||||
print("export")
|
# Create file
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
new_file_name = F"{now.strftime('%Y-%m-%dT%H.%M.%S')}-id{img_id}.png"
|
||||||
|
|
||||||
|
# Put data
|
||||||
|
file_path = pathlib.Path(path, new_file_name)
|
||||||
|
# print(file_path)
|
||||||
|
|
||||||
|
imgpil = ImageTk.getimage(self.tk_imgs[img_id])
|
||||||
|
imgpil.save(file_path, "PNG" )
|
||||||
|
imgpil.close()
|
||||||
|
|
||||||
|
print(f"Exported Image ID {img_id} to {os.path.join(path, new_file_name)}")
|
||||||
else:
|
else:
|
||||||
print("Nothing to export!")
|
print("Nothing to export!")
|
||||||
|
|
||||||
@ -206,6 +222,7 @@ class MainApp:
|
|||||||
|
|
||||||
def update(self, event=None):
|
def update(self, event=None):
|
||||||
path = self.img_path.get()
|
path = self.img_path.get()
|
||||||
|
# print(path)
|
||||||
|
|
||||||
if path != None and path != "":
|
if path != None and path != "":
|
||||||
# Get all images at current path
|
# Get all images at current path
|
||||||
|
Loading…
Reference in New Issue
Block a user