Module albow.dialog.DirectoryPathView
Source code
from pygame import Surface
from albow.core.ui.Widget import Widget
class DirectoryPathView(Widget):
def __init__(self, width, client, **kwds):
super().__init__(**kwds)
self.set_size_for_text(width)
self.client = client
def draw(self, surface: Surface):
frame = self.get_margin_rect()
image = self.font.render(self.client.directory, True, self.fg_color)
tw = image.get_width()
mw = frame.width
if tw <= mw:
x = 0
else:
x = mw - tw
surface.blit(image, (frame.left + x, frame.top))
Classes
class DirectoryPathView (width, client, **kwds)
-
The Widget class is the base class for all widgets. A widget occupies a rectangular area of the PyGame screen to which all drawing in it is clipped, and it may receive mouse and keyboard events. A widget may also contain subwidgets.
Note
Due to a limitation of PyGame subsurfaces, a widget's rectangle must be entirely contained within that of its parent widget. An exception will occur if this is violated.
- Reading the following attributes retrieves the corresponding values from the widget's rect.
- Assigning to them changes the size and position of the widget.
-
Additionally, if the size of the widget is changed via these attributes, the size and position of its subwidgets is updated according to each subwidget's anchor attribute.
left, right, top, bottom, width, height, size, topleft, topright, bottomleft, bottomright, midleft, midright, midtop, midbottom, center, centerx, centery
This does not happen if the rect is modified directly.
Creates a new widget, initially without any parent. If a rect is given, it specifies the new widget's initial s ize and position relative to its parent.
Args
rect
- A PyGame rectangle defining the portion of the parent widget's coordinate system occupied by the
widget. Modifying this rectangle changes the widget's size and position.
**kwds
- Additional attributes specified as key-value pairs
Source code
class DirectoryPathView(Widget): def __init__(self, width, client, **kwds): super().__init__(**kwds) self.set_size_for_text(width) self.client = client def draw(self, surface: Surface): frame = self.get_margin_rect() image = self.font.render(self.client.directory, True, self.fg_color) tw = image.get_width() mw = frame.width if tw <= mw: x = 0 else: x = mw - tw surface.blit(image, (frame.left + x, frame.top))
Ancestors
Inherited members
Widget
:add
add_anchor
add_centered
anchor
attention_lost
augment_mouse_event
bg_color
bg_image
border_color
border_width
call_handler
call_parent_handler
defer_drawing
dismiss
draw
draw_over
fg_color
focus
focus_switch
font
get_cursor
get_focus
get_margin_rect
get_root
get_top_widget
get_visible
global_to_local
has_focus
inherited
invalidate
is_gl_container
key_down
key_up
local_to_global
margin
menu_bar
parent
parent_resized
present
rect
relative_mode
remove
remove_anchor
resized
scale_bg
sel_color
set_parent
set_size_for_text
tab_stop
visible