Ejemplo n.º 1
0
def gg_content_get(obj, part, data):
    if part == "elm.swallow.icon":
        im = elementary.Image(obj)
        im.file_set("images/" + random.choice(images))
        im.size_hint_aspect_set(evas.EVAS_ASPECT_CONTROL_BOTH, 1, 1)
        return im
    return None
Ejemplo n.º 2
0
    frame = elementary.Frame(win)
    frame.label_set("Test")
    frame.show()

    table = elementary.Table(win)
    table.show()
    table.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
#    frame.content_set(table)

    bx = elementary.Box(win)
    win.resize_object_add(bx)
    bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    bx.show()
    frame.content_set(bx)

    image = elementary.Image(win)
#    #image.size_set(300, 500)
#    image.resize(600, 400)
    image.file_set("/tmp/ca_par_jour.png")
#    #image.size_hint_aspect_set(evas.EVAS_ASPECT_CONTROL_BOTH, 1, 1)
    image.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    image.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
#    #icon.scale_set(0, 0)
#    #win.resize_object_add(icon)
#    tb.pack(image, 0, 3, 7, 3)
    image.show()

    bx.pack_end(image)
#    table.pack(image, 0, 0, 1, 1)

#    win.size_hint_min_set(160, 160)
Ejemplo n.º 3
0
def application_start(fileName, settings):
    # saved state of the file
    global file_is_saved
    file_is_saved = True

    # takes settings from file or uses default ones
    global style
    if settings is not None:
        style = settings
    else:
        style = "DEFAULT='color=#000 left_margin=2 right_margin=2 font_source=/usr/share/elementary/themes/default.edj font_size=10.000000 font=Sans:style=Regular'em='+ font_style=Oblique'link='+ color=#800 underline=on underline_color=#8008'hilight='+ font_weight=Bold'preedit='+ underline=on underline_color=#000'preedit_sel='+ backing=on backing_color=#000 color=#FFFFFF'"

    # Create the window title and boarder
    window = elementary.StandardWindow("Etext", "Etext - Untitled")
    window.show()

    # Add window Icon
    icon = elementary.Image(window)
    icon.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    icon.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    icon.file_set(
        'Etext.png'
    )  # assumes image icon is in local dir, may need to change later
    icon.show()
    window.icon_object_set(icon.object_get())

    # creates textbox to hold text
    textbox = elementary.Entry(window)
    textbox.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    textbox.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    textbox.callback_changed_user_add(
        file_saved, window)  # allows program to know when file is saved
    textbox.scrollable_set(
        True)  # creates scrollbars rather than enlarge window
    textbox.line_wrap_set(
        False)  # does not allow line wrap (can be changed by user)
    textbox.autosave_set(False)  # set to false to reduce disk I/O
    textbox.show()

    # If opened from command line or file manager with the intent of displaying a specific file
    # display this file and change the window title to reflect the current file open.
    if fileName != None:
        textbox.file_set(fileName, elementary.ELM_TEXT_FORMAT_PLAIN_UTF8)
        window.title_set("Etext - " + fileName)

    # what to do when close request is sent
    window.callback_delete_request_add(close_safely, window, textbox)

    # window keybindings
    window.elm_event_callback_add(keybind, window, textbox)

    # create a top menu (toolbar)
    # open button (opens a file)
    open_button = elementary.Button(window)
    open_button.text = "Open"
    open_button.callback_pressed_add(open_pressed, window, textbox)
    open_button.show()

    # new button (clears the editor)
    new_button = elementary.Button(window)
    new_button.text = "New"
    new_button.callback_pressed_add(new_pressed, window, textbox)
    new_button.show()

    # Save As Button (allows saving of new file)
    saveas_button = elementary.Button(window)
    saveas_button.text = "Save As"
    saveas_button.callback_pressed_add(saveas_pressed, window, textbox)
    saveas_button.show()

    # Save Button (save changes to a file)
    save_button = elementary.Button(window)
    save_button.text = "Save"
    save_button.callback_pressed_add(save_pressed, window, textbox)
    save_button.show()

    # Word Wrap toggle (changes the state of word wrap)
    wordwrap_check = elementary.Check(window)
    wordwrap_check.text = "Word Wrap"
    wordwrap_check.callback_changed_add(wordwrap_pressed, window, textbox)
    wordwrap_check.show()

    # Font Button (allows user to change the font size and type)
    font_button = elementary.Button(window)
    font_button.text = "Font"
    font_button.callback_pressed_add(font_pressed, window, textbox)
    font_button.show()

    # About Button (displays about popup)
    about_button = elementary.Button(window)
    about_button.text = "About"
    about_button.callback_pressed_add(about_pressed, window)
    about_button.show()

    # create a horz box to hold buttons
    top_menu = elementary.Box(window)
    top_menu.horizontal_set(True)
    top_menu.size_hint_weight_set(0, 0)
    top_menu.size_hint_align_set(0.01, 0.01)
    top_menu.pack_end(open_button)
    top_menu.pack_end(new_button)
    top_menu.pack_end(save_button)
    top_menu.pack_end(saveas_button)
    top_menu.pack_end(wordwrap_check)
    top_menu.pack_end(font_button)
    top_menu.pack_end(about_button)

    top_menu.show()

    # Create a box to hold everything
    full_package = elementary.Box(window)
    full_package.padding_set(1, 1)
    full_package.size_hint_weight_set(evas.EVAS_HINT_EXPAND,
                                      evas.EVAS_HINT_EXPAND)
    full_package.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)

    full_package.pack_end(top_menu)
    full_package.pack_end(textbox)

    full_package.show()
    window.resize_object_add(full_package)

    tmp = textbox.textblock_get().style_set(style)
    window.resize(600, 400)

    print textbox.content_get()
Ejemplo n.º 4
0
def notify_show(bt, win, orient):

    notify = elementary.Notify(win)
    notify.repeat_events_set(False)
    notify.orient_set(elementary.ELM_NOTIFY_ORIENT_CENTER)

    frame = elementary.Frame(win)
    frame.label_set("Graphiques")
    frame.show()

    notify.content_set(frame)

#    tb = elementary.Table(win)
    #tb.homogenous_set(True)
#    tb.show()
#    frame.content_set(tb)

    vbox = elementary.Box(win)
    vbox.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    vbox.show()
    frame.content_set(vbox)

    hbox = elementary.Box(win)
    hbox.horizontal_set(True)
    hbox.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    hbox.show()

    frame_data = elementary.Frame(win)
    frame_data.label_set("Données")
    frame_data.show()
    table_data = elementary.Table(win)
    table_data.show()
    frame_data.content_set(table_data)

    x_1 = 0
    y_1 = 0
    for log in LogType.objects.filter(id__gt=8).exclude(nom="maj_stats"):
        check = elementary.Check(win)
        check.label_set(log.description)
        check.callback_changed_add(add_check)
        check.show()
        table_data.pack(check, x_1, y_1, 1, 1)
        if x_1 > 2:
            x_1 = 0
            y_1 += 1
        else:
            x_1 += 1

    frame_type = elementary.Frame(win)
    frame_type.label_set("Type")
    frame_type.show()
    table_type = elementary.Table(win)
    table_type.show()
    frame_type.content_set(table_type)

    rd = elementary.Radio(win)
    rd.state_value_set(0)
    rd.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    rd.size_hint_align_set(evas.EVAS_HINT_FILL, 0.5)
    rd.label_set("entier")
    table_type.pack(rd, 0, 0, 1, 1)
    rd.show()
    rdg = rd

    rd = elementary.Radio(win)
    rd.state_value_set(1)
    rd.label_set("par mois")
    rd.group_add(rdg)
    table_type.pack(rd, 0, 1, 1, 1)
    rd.show()

    rd = elementary.Radio(win)
    rd.state_value_set(2)
    rd.group_add(rdg)
    rd.label_set("par semaine")
    table_type.pack(rd, 1, 0, 1, 1)
    rd.show()

    rd = elementary.Radio(win)
    rd.state_value_set(3)
    rd.group_add(rdg)
    rd.label_set("par année")
    table_type.pack(rd, 1, 1, 1, 1)
    rd.show()

    toggle = elementary.Toggle(win)
    toggle.label_set("Légende")
    toggle.states_labels_set("avec", "sans")
    toggle.show()
    toggle.state_set(True)
    table_type.pack(toggle, 0, 2, 2, 1)

    frame_interval = elementary.Frame(win)
    frame_interval.label_set("Interval")
    frame_interval.show()
    table_interval = elementary.Table(win)
    table_interval.show()
    frame_interval.content_set(table_interval)

    label = elementary.Label(win)
    label.label_set("Début:")
    label.show()
    table_interval.pack(label, 0, 0, 1, 1)

    button = elementary.Button(win)
    button.label_set("31")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 1, 0, 1, 1)

    button = elementary.Button(win)
    button.label_set("Janvier")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 2, 0, 1, 1)

    button = elementary.Button(win)
    button.label_set("2011")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 3, 0, 1, 1)

    label = elementary.Label(win)
    label.label_set("Fin:")
    label.show()
    table_interval.pack(label, 0, 1, 1, 1)

    button = elementary.Button(win)
    button.label_set("31")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 1, 1, 1, 1)

    button = elementary.Button(win)
    button.label_set("Décembre")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 2, 1, 1, 1)

    button = elementary.Button(win)
    button.label_set("2011")
    button.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    button.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    button.show()
    table_interval.pack(button, 3, 1, 1, 1)

    bt = elementary.Button(win)
    bt.label_set("Afficher")
    bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    bt.show()
    table_interval.pack(bt, 0, 2, 4, 1)

    hbox.pack_end(frame_data)
    hbox.pack_end(frame_type)
    hbox.pack_end(frame_interval)
    #tb.pack(frame_data, 0, 0, 3, 3)
    #tb.pack(frame_type, 3, 0, 2, 3)
    #tb.pack(frame_interval, 5, 0, 2, 3)

    vbox.pack_end(hbox)

#    frame_image = elementary.Frame(win)
#    frame_image.label_set("Interval")
#    frame_image.show()
#    table_interval = elementary.Table(win)
#    table_interval.show()
#    frame_interval.content_set(table_interval)

#    box_image = elementary.Box(win)
#    box_image.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
#    box_image.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    #win.resize_object_add(box0)
#    box_image.show()
#    frame_image.content_set(box_image)

#    bg = elementary.Background(win)
#    #frame_image.resize_object_add(bg)
#    bg.file_set("/tmp/ca_par_jour.png")
#    bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
#    bg.show()
#    frame_image.content_set(bg)

    image = elementary.Image(win)
#    #image.size_set(300, 500)
    #image.resize(600, 400)
    image.file_set("ca_par_jour.png")
#    #image.size_hint_aspect_set(evas.EVAS_ASPECT_CONTROL_BOTH, 1, 1)
    image.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    image.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
#    #icon.scale_set(0, 0)
#    #win.resize_object_add(icon)
#    tb.pack(image, 0, 3, 7, 3)
    image.show()
    vbox.pack_end(image)
#    box_image.pack_end(image)

    #tb.pack(box_image, 0, 3, 7, 3)

    sp = elementary.Separator(win)
    sp.horizontal_set(True)
    sp.show()
    #tb.pack(sp, 0, 6, 7, 1)
    vbox.pack_end(sp)

    bt = elementary.Button(win)
    bt.label_set("Retour")
    bt.callback_clicked_add(notify_close, notify)
    bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    bt.show()
    #tb.pack(bt, 0, 7, 7, 1)
    vbox.pack_end(bt)

    notify.show()