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 tkinter as tk
|
||||
from tkinter import filedialog, ttk
|
||||
from tkinter import ttk
|
||||
|
||||
from coretk.appconfig import BACKGROUNDS_PATH
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.images import Images
|
||||
from coretk.themes import PADX, PADY
|
||||
from coretk.widgets import image_chooser
|
||||
|
||||
|
||||
class CanvasBackgroundDialog(Dialog):
|
||||
|
@ -126,14 +127,7 @@ class CanvasBackgroundDialog(Dialog):
|
|||
button.grid(row=0, column=1, sticky="ew")
|
||||
|
||||
def click_open_image(self):
|
||||
filename = filedialog.askopenfilename(
|
||||
initialdir=str(BACKGROUNDS_PATH),
|
||||
title="Open",
|
||||
filetypes=(
|
||||
("images", "*.gif *.jpg *.png *.bmp *pcx *.tga ..."),
|
||||
("All Files", "*"),
|
||||
),
|
||||
)
|
||||
filename = image_chooser(self, BACKGROUNDS_PATH)
|
||||
if filename:
|
||||
self.filename.set(filename)
|
||||
self.draw_preview()
|
||||
|
|
|
@ -4,6 +4,7 @@ from pathlib import Path
|
|||
from tkinter import ttk
|
||||
|
||||
from coretk import nodeutils
|
||||
from coretk.appconfig import ICONS_PATH
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.images import Images
|
||||
from coretk.nodeutils import NodeDraw
|
||||
|
@ -179,7 +180,7 @@ class CustomNodesDialog(Dialog):
|
|||
self.image_button.config(image="")
|
||||
|
||||
def click_icon(self):
|
||||
file_path = image_chooser(self)
|
||||
file_path = image_chooser(self, ICONS_PATH)
|
||||
if file_path:
|
||||
image = Images.create(file_path, nodeutils.ICON_SIZE)
|
||||
self.image = image
|
||||
|
|
|
@ -4,6 +4,7 @@ from functools import partial
|
|||
from tkinter import ttk
|
||||
|
||||
from coretk import nodeutils
|
||||
from coretk.appconfig import ICONS_PATH
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.dialogs.emaneconfig import EmaneModelDialog
|
||||
from coretk.images import Images
|
||||
|
@ -209,7 +210,7 @@ class NodeConfigDialog(Dialog):
|
|||
dialog.show()
|
||||
|
||||
def click_icon(self):
|
||||
file_path = image_chooser(self)
|
||||
file_path = image_chooser(self, ICONS_PATH)
|
||||
if file_path:
|
||||
self.image = Images.create(file_path, nodeutils.ICON_SIZE)
|
||||
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 coretk import themes
|
||||
from coretk.appconfig import ICONS_PATH
|
||||
from coretk.themes import FRAME_PAD, PADX, PADY
|
||||
|
||||
INT_TYPES = {
|
||||
|
@ -239,11 +238,11 @@ class Spinbox(ttk.Entry):
|
|||
self.tk.call(self._w, "set", value)
|
||||
|
||||
|
||||
def image_chooser(parent):
|
||||
def image_chooser(parent, path):
|
||||
return filedialog.askopenfilename(
|
||||
parent=parent,
|
||||
initialdir=str(ICONS_PATH),
|
||||
title="Select Icon",
|
||||
initialdir=str(path),
|
||||
title="Select",
|
||||
filetypes=(
|
||||
("images", "*.gif *.jpg *.png *.bmp *pcx *.tga ..."),
|
||||
("All Files", "*"),
|
||||
|
|
Loading…
Add table
Reference in a new issue