App-InvestSim
view release on metacpan or search on metacpan
lib/App/InvestSim/GUI.pm view on Meta::CPAN
if (Tkx::expr('$tcl_platform(platform)') eq 'windows') {
$root->g_wm_iconbitmap(catfile($res_dir, 'icon.ico'));
} else {
# On Linux, we cant read .ico files directly.
my $icon = Tkx::widget->new(Tkx::image_create_photo());
$icon->read(catfile($res_dir, 'sources', 'icon_32.png'));
# We could pass several images of different sizes here.
$root->g_wm_iconphoto($icon);
}
# We're copying the font used by the TreeView style and adding an 'bold'
# option to it, it will be used by the 'total' line.
my $default_treeview_font = Tkx::ttk__style('lookup', 'TreeView', '-font');
my $treeview_total_font = Tkx::font('create');
Tkx::font('configure', $treeview_total_font, Tkx::SplitList(Tkx::font('configure', $default_treeview_font)));
Tkx::font('configure', $treeview_total_font, -weight => 'bold');
# Build the left bar with various parameters.
{
my $frame = $root->new_ttk__frame(-padding => 3);
$frame->g_grid(-column => 0, -row => 0, -rowspan => 3, -sticky => "we");
my $row = 0;
for my $c (['invested', "Valeur du bien", \&format_euro, "Prix d'achat du bien, hors frais de notaire."],
['tax_rate', "Taux d'imposition marginal", \&format_percent],
['base_rent', "Loyer brut initial", \&format_euro],
lib/App/InvestSim/GUI.pm view on Meta::CPAN
$root->g_grid_rowconfigure(3, -weight => 1);
{
my $frame = $root->new_ttk__frame(-padding => 3, -height => 550);
$frame->g_grid_propagate(0);
$frame->g_grid(-column => 0, -row => 3, -columnspan => 3, -sticky => "nwes");
$frame->g_grid_columnconfigure(0, -weight => 1);
$frame->g_grid_rowconfigure(0, -weight => 1);
$display_table = $frame->new_ttk__treeview(-height => ($values{duration} // 20) + 2);
$display_table->g_grid(-column => 0, -row => 0, -rowspan => 2, -sticky => "nwes");
# We're setting a specific font for items with the tag 'total'.
$display_table->m_tag('configure', 'total', -font => $treeview_total_font);
#my $hscroll = $frame->new_tk__scrollbar(-orient => "horizontal", -command => [$display_table, "xview"]);
#$hscroll->g_grid(-column => 0, -row => 1, -sticky => "we");
my $vscroll = $frame->new_ttk__scrollbar(-orient => "vertical", -command => [$display_table, "yview"]);
$vscroll->g_grid(-column => 1, -row => 0, -sticky => "ns");
$frame->new_ttk__sizegrip()->g_grid(-column => 1, -row => 1, -sticky => "se");
$display_table->configure(-yscrollcommand => [$vscroll, "set"]);
#$display_table->configure(-xscrollcommand => [$hscroll, "set"]);
my @headings = ('Année', 'Loyer net', 'Placements', 'Principal du prêt', 'Intérêts du prêt', 'Frais du prêt', 'Revenus imposable', 'Déficit déductible', 'Impôt', 'Solde annuel', 'Capital');
# We're not using the name of the columns (c1, c2, ...) we're only using their
# index (#0, #1, ...), including #0 the index of the first implicit column.
$display_table->m_configure(-columns => [map { "c$_" } 1..$#headings ]);
for my $c (0..$#headings) {
my $width = Tkx::font_measure(Tkx::ttk__style_lookup('Heading', '-font'), $headings[$c]);
$display_table->m_heading("#${c}", -text => $headings[$c]);
$display_table->m_column("#${c}", -width => $width, -anchor => 'e');
}
}
# Finally, we create a small menu.
{
my $menu = $root->new_menu;
$root->configure(-menu => $menu);
my $file = $menu->new_menu;
( run in 1.801 second using v1.01-cache-2.11-cpan-5735350b133 )