source: framspy/gui/widgets/ScrolledText.py @ 1277

Last change on this file since 1277 was 1198, checked in by Maciej Komosinski, 23 months ago

Added simple Python GUI for Framsticks library/server

File size: 1.0 KB
Line 
1from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
2from tkinter.constants import RIGHT, LEFT, Y, BOTH
3
4#source: https://github.com/python/cpython/blob/main/Lib/tkinter/scrolledtext.py
5
6class ScrolledText(Text):
7    def __init__(self, master=None, **kw):
8        self.frame = Frame(master)
9        self.vbar = Scrollbar(self.frame)
10        self.vbar.pack(side=RIGHT, fill=Y)
11
12        kw.update({'yscrollcommand': self.vbar.set})
13        Text.__init__(self, self.frame, **kw)
14        self.pack(side=LEFT, fill=BOTH, expand=True)
15        self.vbar['command'] = self.yview
16
17        # Copy geometry methods of self.frame without overriding Text methods -- hack!
18        text_meths = vars(Text).keys()
19        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
20        methods = methods.difference(text_meths)
21
22        for m in methods:
23            if m[0] != '_' and m != 'config' and m != 'configure':
24                setattr(self, m, getattr(self.frame, m))
25
26    def __str__(self):
27        return str(self.frame)
Note: See TracBrowser for help on using the repository browser.