# Copyright 2017 The Tangram Developers. See the AUTHORS file at the
# top-level directory of this distribution and at
# https://github.com/renatoGarcia/tangram/blob/master/AUTHORS.
#
# This file is part of Tangram.
#
# Tangram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Tangram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tangram in the COPYING and COPYING.LESSER files.
# If not, see <http://www.gnu.org/licenses/>.
from typing import Optional
from gi.repository import Gtk
from .._base import Base
from .._gui_thread import on_gtk_thread
from .._utility import Signal
[docs]class Vertical(Base):
[docs] @on_gtk_thread
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
self._gtk_obj = Gtk.Grid()
self._gtk_obj.set_orientation(Gtk.Orientation.VERTICAL)
self._children = args
for widget in self._children:
self._gtk_obj.add(widget._gtk_obj)
[docs]class Horizontal(Base):
[docs] @on_gtk_thread
def __init__(self, *args, spacing=5, **kwargs):
super().__init__(**kwargs)
self._gtk_obj = Gtk.Grid()
self._gtk_obj.set_orientation(Gtk.Orientation.HORIZONTAL)
self._gtk_obj.set_column_spacing(spacing)
self._children = args
for widget in self._children:
self._gtk_obj.add(widget._gtk_obj)
[docs]class Message(Base):
"""Shows a message composed by ``[title][text]``.
Both ``title`` and ``text`` strings are optinal, and can contain *Pango Markup
Format*[#pmf]_ tags.
.. [#pmf] https://developer.gnome.org/pango/stable/PangoMarkupFormat.html
"""
[docs] @on_gtk_thread
def __init__(self,
*,
title: Optional[str] = None,
text: Optional[str] = None,
name: Optional[str] = None) -> None:
super().__init__(name=name)
self._gtk_obj = Gtk.Grid()
self._gtk_obj.set_orientation(Gtk.Orientation.HORIZONTAL)
self._title = Gtk.Label(label=title)
self._gtk_obj.add(self._title)
self._text = Gtk.Label(label=text, use_markup=True)
self._gtk_obj.add(self._text)
self._gtk_obj.set_valign(Gtk.Align.CENTER)
def title():
doc = """Message title."""
@on_gtk_thread
def fget(self):
return self._title.get_label()
@on_gtk_thread
def fset(self, value):
self._title.set_label(value)
return locals()
title = property(**title())
def text():
doc = """Message text."""
@on_gtk_thread
def fget(self):
return self._text.get_label()
@on_gtk_thread
def fset(self, value):
self._text.set_label(value)
return locals()
text = property(**text())