updated canvas wallpaper selection to use common image chooser function
This commit is contained in:
parent
80609da90a
commit
e72f44ed85
4 changed files with 10 additions and 15 deletions
|
@ -3,12 +3,13 @@ set wallpaper
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog, ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from coretk.appconfig import BACKGROUNDS_PATH
|
from coretk.appconfig import BACKGROUNDS_PATH
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
from coretk.images import Images
|
from coretk.images import Images
|
||||||
from coretk.themes import PADX, PADY
|
from coretk.themes import PADX, PADY
|
||||||
|
from coretk.widgets import image_chooser
|
||||||
|
|
||||||
|
|
||||||
class CanvasBackgroundDialog(Dialog):
|
class CanvasBackgroundDialog(Dialog):
|
||||||
|
@ -126,14 +127,7 @@ class CanvasBackgroundDialog(Dialog):
|
||||||
button.grid(row=0, column=1, sticky="ew")
|
button.grid(row=0, column=1, sticky="ew")
|
||||||
|
|
||||||
def click_open_image(self):
|
def click_open_image(self):
|
||||||
filename = filedialog.askopenfilename(
|
filename = image_chooser(self, BACKGROUNDS_PATH)
|
||||||
initialdir=str(BACKGROUNDS_PATH),
|
|
||||||
title="Open",
|
|
||||||
filetypes=(
|
|
||||||
("images", "*.gif *.jpg *.png *.bmp *pcx *.tga ..."),
|
|
||||||
("All Files", "*"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
if filename:
|
if filename:
|
||||||
self.filename.set(filename)
|
self.filename.set(filename)
|
||||||
self.draw_preview()
|
self.draw_preview()
|
||||||
|
|
|
@ -4,6 +4,7 @@ from pathlib import Path
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from coretk import nodeutils
|
from coretk import nodeutils
|
||||||
|
from coretk.appconfig import ICONS_PATH
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
from coretk.images import Images
|
from coretk.images import Images
|
||||||
from coretk.nodeutils import NodeDraw
|
from coretk.nodeutils import NodeDraw
|
||||||
|
@ -179,7 +180,7 @@ class CustomNodesDialog(Dialog):
|
||||||
self.image_button.config(image="")
|
self.image_button.config(image="")
|
||||||
|
|
||||||
def click_icon(self):
|
def click_icon(self):
|
||||||
file_path = image_chooser(self)
|
file_path = image_chooser(self, ICONS_PATH)
|
||||||
if file_path:
|
if file_path:
|
||||||
image = Images.create(file_path, nodeutils.ICON_SIZE)
|
image = Images.create(file_path, nodeutils.ICON_SIZE)
|
||||||
self.image = image
|
self.image = image
|
||||||
|
|
|
@ -4,6 +4,7 @@ from functools import partial
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from coretk import nodeutils
|
from coretk import nodeutils
|
||||||
|
from coretk.appconfig import ICONS_PATH
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
from coretk.dialogs.emaneconfig import EmaneModelDialog
|
from coretk.dialogs.emaneconfig import EmaneModelDialog
|
||||||
from coretk.images import Images
|
from coretk.images import Images
|
||||||
|
@ -209,7 +210,7 @@ class NodeConfigDialog(Dialog):
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def click_icon(self):
|
def click_icon(self):
|
||||||
file_path = image_chooser(self)
|
file_path = image_chooser(self, ICONS_PATH)
|
||||||
if file_path:
|
if file_path:
|
||||||
self.image = Images.create(file_path, nodeutils.ICON_SIZE)
|
self.image = Images.create(file_path, nodeutils.ICON_SIZE)
|
||||||
self.image_button.config(image=self.image)
|
self.image_button.config(image=self.image)
|
||||||
|
|
|
@ -5,7 +5,6 @@ from tkinter import filedialog, font, ttk
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk import themes
|
from coretk import themes
|
||||||
from coretk.appconfig import ICONS_PATH
|
|
||||||
from coretk.themes import FRAME_PAD, PADX, PADY
|
from coretk.themes import FRAME_PAD, PADX, PADY
|
||||||
|
|
||||||
INT_TYPES = {
|
INT_TYPES = {
|
||||||
|
@ -239,11 +238,11 @@ class Spinbox(ttk.Entry):
|
||||||
self.tk.call(self._w, "set", value)
|
self.tk.call(self._w, "set", value)
|
||||||
|
|
||||||
|
|
||||||
def image_chooser(parent):
|
def image_chooser(parent, path):
|
||||||
return filedialog.askopenfilename(
|
return filedialog.askopenfilename(
|
||||||
parent=parent,
|
parent=parent,
|
||||||
initialdir=str(ICONS_PATH),
|
initialdir=str(path),
|
||||||
title="Select Icon",
|
title="Select",
|
||||||
filetypes=(
|
filetypes=(
|
||||||
("images", "*.gif *.jpg *.png *.bmp *pcx *.tga ..."),
|
("images", "*.gif *.jpg *.png *.bmp *pcx *.tga ..."),
|
||||||
("All Files", "*"),
|
("All Files", "*"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue