Skip to content

Commit

Permalink
Auto-adapt Copyable width to prevent main widget stretching
Browse files Browse the repository at this point in the history
  • Loading branch information
Baharis committed Feb 20, 2025
1 parent a6aa242 commit 63afa09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/instamatic/gui/about_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tkinter import Label as tkLabel
from tkinter.font import Font, nametofont
from tkinter.ttk import *
from typing import Callable
from typing import Callable, Optional

import instamatic

Expand Down Expand Up @@ -32,7 +32,9 @@ def get_background_of_widget(widget):

class Copyable(Text):
def __init__(self, master=None, text: str = '', **kwargs) -> None:
kwargs = {**kwargs, 'bg': get_background_of_widget(master), 'relief': 'flat'}
kwargs['bg'] = kwargs.get('bg', get_background_of_widget(master))
kwargs['relief'] = kwargs.get('relief', 'flat')
kwargs['width'] = kwargs.get('width', len(text))
super().__init__(master, **kwargs)
self.insert(1.0, text)
self.configure(state='disabled', font=nametofont('TkDefaultFont'))
Expand Down

0 comments on commit 63afa09

Please sign in to comment.