Package dtk :: Package ui :: Module application :: Class Application

Class Application

source code


This is the base class of every program based on deepin-ui. Every program should realize it.

Instance Methods
 
__init__(self, app_support_colormap=True)
Initialize the Application class.
source code
 
init(self)
This do the remain initialize step.
source code
 
add_titlebar(self, button_mask=["theme","menu","max","min","close"], icon_dpixbuf=None, app_name=None, title=None, add_separator=False, show_title=True)
Add titlebar to the application.
source code
 
close_window(self, widget)
Close the window when the close button is clicked.
source code
 
show_titlebar(self)
Show title bar of the window.
source code
 
hide_titlebar(self)
Hide the title bar.
source code
 
raise_to_top(self)
Raise the window to the top of the window stack.
source code
 
set_title(self, title)
Set the application title.
source code
 
set_default_size(self, default_width, default_height)
Set the default size of the window.
source code
 
set_icon(self, icon_dpixbuf)
Set the icon of the application.
source code
 
destroy(self, widget, data=None)
Destroy the window and quit the program.
source code
 
run(self)
Show the window and start the mainloop.
source code
 
set_skin_preview(self, preview_pixbuf)
Set the skin preview of the application.
source code
 
theme_callback(self, widget)
Invoked when the theme button is clicked.
source code
 
menu_callback(self, widget)
Invoked when the menu button is clicked.
source code
 
set_menu_callback(self, callback)
Set the menu_button_callback function.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, app_support_colormap=True)
(Constructor)

source code 

Initialize the Application class.

Parameters:
  • app_support_colormap - Set False if your program don't allow manipulate colormap, such as mplayer, otherwise you should keep this option as True.
Overrides: object.__init__

init(self)

source code 

This do the remain initialize step.

It Initializes the window and some important signal such as "destroy".

add_titlebar(self, button_mask=["theme","menu","max","min","close"], icon_dpixbuf=None, app_name=None, title=None, add_separator=False, show_title=True)

source code 

Add titlebar to the application.

Connect click signal of the standard button to default callback.

Parameters:
  • button_mask - A list of string, each of which stands for a standard button on top right of the window. By default, it's ["theme", "menu", "max", "min", "close"].
  • icon_dpixbuf - The icon pixbuf of type dtk.ui.theme.DynamicPixbuf. By default, it is None.
  • app_name - The name string of the application, which will be displayed just next to the icon_dpixbuf. By default, it is None.
  • title - The title string of the window, which will be displayed on the center of the titlebar. By default, it is None.
  • add_separator - If True, add a line between the titlebar and the body of the window. By default, it's False.
  • show_title - If False, the titlebar will not be displayed. By default, it's True.

close_window(self, widget)

source code 

Close the window when the close button is clicked.

Parameters:
  • widget - A widget of Gtk.Widget. Passed by gtk.

show_titlebar(self)

source code 

Show title bar of the window.

By default, it is invoked at the last step of add_titlebar.

raise_to_top(self)

source code 

Raise the window to the top of the window stack.

Decorators:
  • @post_gui

set_title(self, title)

source code 

Set the application title.

Parameters:
  • title - The title string of the application.

set_default_size(self, default_width, default_height)

source code 

Set the default size of the window.

Parameters:
  • default_width - Default width in pixels of the application, once set, application don't allow smaller than width.
  • default_height - Default height in pixels of the application, once set, application don't allow smaller than height.

set_icon(self, icon_dpixbuf)

source code 

Set the icon of the application.

This icon is used by the window manager or the dock.

Parameters:
  • icon_dpixbuf - The icon pixbuf of dtk.ui.theme.DynamicPixbuf.

destroy(self, widget, data=None)

source code 

Destroy the window and quit the program.

Parameters:
  • widget - Not used.
  • data - Not used.

run(self)

source code 

Show the window and start the mainloop.

You must use this function at last of program, otherwise program will run in loop too early that all code after application.run won't execute until program exit.

set_skin_preview(self, preview_pixbuf)

source code 

Set the skin preview of the application.

Parameters:
  • preview_pixbuf - A pixbuf of type dtk.ui.theme.DynamicPixbuf.

Note: The size of preview_pixbuf must be proportional to the size of program, otherwise adjust skin will got wrong coordinate.

theme_callback(self, widget)

source code 

Invoked when the theme button is clicked.

Parameters:
  • widget - Not used.
Returns:
Always return False

menu_callback(self, widget)

source code 

Invoked when the menu button is clicked.

Parameters:
  • widget - Not used.
Returns:
Always return False

set_menu_callback(self, callback)

source code 

Set the menu_button_callback function.

Parameters:
  • callback - A function which is invoked when the menu button is clicked.