News:

Scarica subito LibreOffice 24.2 ancora più compatibile con la nota suite per ufficio commerciale.

Menu principale

introduzione a Idle-Python 2.7

Aperto da andromeda., Giovedì 14 Febbraio 2013, 09:44:16

Discussione precedente - Discussione successiva

andromeda.

Per scaricarlo basta digitare idle nel gestore pacchetti, attenzione non scaricare la versione 3 presente nei repository, non si differenzia molto dalla 2.* (bisogna mettere la parentesi tonda dopo l'istruzione print, non viene più implementata l'istruzione raw_input, ecc.) ma per iniziare consiglio la vecchia versione in quanto si trovano molti programmi già pronti che poi si potranno convertire nella nuova versione.

Per iniziare ho scelto Idle-Python per la semplicità e la versatilità, da noyare che Red Hat ha implementato in python il proprio tool di installazione.

La differenza più importante rispetto ad  altri semplici linguaggi di alto livello come il basic per esempio è che non è implementata l'istruzione goto per cui per i cicli verranno utilizzati for, while,  if , else, elif.

Vediamo ora le istruzioni fondamentali in un file pdf :

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CD4QFjAB&url=http%3A%2F%2Fphloorzero.altervista.org%2Fdocumenti%2Findice%2520istruzioni%2520%2520python%2520NiktorTheNat.pdf&ei=f6EcUZiLFc_EsgbowIBw&usg=AFQjCNHFeLM7DMpB1eu4rl1VO2coHKT5Ow&sig2=v36AfjIMcoluVz0xNYFHZQ&bvm=bv.42452523,d.Yms

Buon divertimento

bobol

Prima di tutto, Auguri per la nuova sezione e per il tuo nuovo incarico ;)......
...dunque, partendo dal presupposto che io non ci capisco nulla  ;D, devo dire che la guida base che hai linkato fà sembrare la scrittura in codice relativamente facile, i comandi sono semplici e chiari......chissà magari potrei provarci ad impegnarmi.....ma non so a cosa possa servirmi  :D

ken

L' ho installato!  :ok:
....a quando la prima lezione?  :entu:

andromeda.

Grazie, lo sto studiando anch'io, in questo momento sto approfondendo la logica dei cicli if while visto che non è implementato if goto.

L'obiettivo che mi sono prefissato è quello di creare delle piccole applicazioni dotate di interfaccia grafica .

Ciao


Pedro

Bene, quando lo riterrai opportuno per le gui puoi farti aiutare da wxglade  :ok:


andromeda.

Grazie Pedro,
ero proprio quello che cercavo.
Lavorare con Linux è meravigioso, sopratutto con la collaborazione di grandi sviluppatori.
Ciao

Harald

sto usando wxGlade da 20 min, voglio fare una programmino con dei tasti per installare delle utilita' (per me) fondamentali a chi installa una distro pulita, l'interfaccia e stata facila da fare, i pulsanti sono perfetti, ora mi chiedo come fare a far eseguire le istruzioni a tali pulsanti, ad esempio:
premo il tasto che ho fatto di nome "java" e dovrebbe installare come si fa da terminale questo:
sudo apt-get install openjdk-7-jre
come si fa?
devo fare dei file con lo script bash tipo questo?
#!/bin/bash

# Questo script installa java

sudo apt-get install openjdk-7-jre -y


exit

e come lo collego al tasto del mio programma?
oppure c'e un altro sistema piu' semplice gia all'interno di wxglade?
:ciao:

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Pedro

Se hai creato i bottoni correttamente con gli eventi, una volta generato il file.py lo apri con un editor di testo e aggiungi in cima al file import commands, spostati infondo al file dove dovresti trovare la stringa con il nome del bottone quindi l'evento da eseguire, qualcosa del genere
def onbtn1(self, event):  # wxGlade: StreamingTv.<event_handler>
        event.Skip()

in mezzo aggiungi il codice che ti occorre in questo modo
def onbtn1(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('sudo apt-get install openjdk-7-jre')
        event.Skip()

ad ogni modo per cose elementari o comunque se sei più per gli script ti consiglio di provare gtkdialog.


Harald

mi sa che manca qualcosa, nel frattempo ti faccio vedere il file.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.4 on Wed Jan 22 21:03:38 2014

import wx

# begin wxGlade: extracode
# end wxGlade


class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, -1, "\nclick botton for\n installing programs\n", style=wx.ALIGN_RIGHT | wx.ALIGN_CENTRE)
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("/home/andrea3/Pubblici/distributor_logo.png", wx.BITMAP_TYPE_ANY))
        self.button_1 = wx.Button(self, -1, "LibreOffice")
        self.button_2 = wx.Button(self, -1, "Gimp")
        self.button_3 = wx.Button(self, -1, "Skype")
        self.button_4 = wx.Button(self, -1, "Qbitorrent")
        self.button_5 = wx.Button(self, -1, "Googleearth")
        self.button_6 = wx.Button(self, -1, "TeamViewer")
        self.button_7 = wx.Button(self, -1, "UbuntuTweak")
        self.button_8 = wx.Button(self, -1, "Wine")
        self.button_9 = wx.Button(self, -1, "Conky-Manager")
        self.button_10 = wx.Button(self, -1, "Java")
        self.button_11 = wx.Button(self, -1, "Firefox")
        self.button_12 = wx.Button(self, -1, "Thunderbird")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("MindOS-Program")
        self.SetSize((406, 528))
        self.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_1.SetMinSize((150, 40))
        self.button_1.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_2.SetMinSize((150, 40))
        self.button_2.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_2.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_3.SetMinSize((150, 40))
        self.button_3.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_3.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_3.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_4.SetMinSize((150, 40))
        self.button_4.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_4.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_4.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_5.SetMinSize((150, 40))
        self.button_5.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_5.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_5.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_6.SetMinSize((150, 40))
        self.button_6.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_6.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_6.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_7.SetMinSize((150, 40))
        self.button_7.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_7.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_7.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_8.SetMinSize((150, 40))
        self.button_8.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_8.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_8.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_9.SetMinSize((150, 40))
        self.button_9.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_9.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_9.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_10.SetMinSize((150, 40))
        self.button_10.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_10.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_10.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_11.SetMinSize((150, 40))
        self.button_11.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_11.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_11.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_12.SetMinSize((150, 40))
        self.button_12.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_12.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_12.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(7, 2, 0, 0)
        grid_sizer_1.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        grid_sizer_1.Add(self.bitmap_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        grid_sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_4, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_5, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_6, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_7, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_8, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_9, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_10, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_11, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_12, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        self.Layout()
        # end wxGlade

# end of class MyFrame
if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()


se riesci a vedere cosa manca...... ;D

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Pedro

Quando crei i bottoni nelle proprietà di wxglade devi andare in Events, qui bisogna attivare il bottone per essere cliccato altrimenti non va, e poi come dicevo prima vanno impostati i comandi, ad ogni modo ti posto il codice corretto, devi solo sostituire comando con quello corretto, java è apposto.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.4 on Wed Jan 22 21:03:38 2014

import wx
import commands

# begin wxGlade: extracode
# end wxGlade


class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, -1, "\nclick botton for\n installing programs\n", style=wx.ALIGN_RIGHT | wx.ALIGN_CENTRE)
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("/home/andrea3/Pubblici/distributor_logo.png", wx.BITMAP_TYPE_ANY))
        self.button_1 = wx.Button(self, -1, "LibreOffice")
        self.button_2 = wx.Button(self, -1, "Gimp")
        self.button_3 = wx.Button(self, -1, "Skype")
        self.button_4 = wx.Button(self, -1, "Qbitorrent")
        self.button_5 = wx.Button(self, -1, "Googleearth")
        self.button_6 = wx.Button(self, -1, "TeamViewer")
        self.button_7 = wx.Button(self, -1, "UbuntuTweak")
        self.button_8 = wx.Button(self, -1, "Wine")
        self.button_9 = wx.Button(self, -1, "Conky-Manager")
        self.button_10 = wx.Button(self, -1, "Java")
        self.button_11 = wx.Button(self, -1, "Firefox")
        self.button_12 = wx.Button(self, -1, "Thunderbird")

        self.__set_properties()
        self.__do_layout()
        self.Bind(wx.EVT_BUTTON, self.onbtn1, self.button_1)
        self.Bind(wx.EVT_BUTTON, self.onbtn2, self.button_2)
        self.Bind(wx.EVT_BUTTON, self.onbtn3, self.button_3)
        self.Bind(wx.EVT_BUTTON, self.onbtn4, self.button_4)
        self.Bind(wx.EVT_BUTTON, self.onbtn5, self.button_5)
        self.Bind(wx.EVT_BUTTON, self.onbtn6, self.button_6)
        self.Bind(wx.EVT_BUTTON, self.onbtn7, self.button_7)
        self.Bind(wx.EVT_BUTTON, self.onbtn8, self.button_8)
        self.Bind(wx.EVT_BUTTON, self.onbtn9, self.button_9)
        self.Bind(wx.EVT_BUTTON, self.onbtn10, self.button_10)
        self.Bind(wx.EVT_BUTTON, self.onbtn11, self.button_11)
        self.Bind(wx.EVT_BUTTON, self.onbtn12, self.button_12)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("MindOS-Program")
        self.SetSize((406, 528))
        self.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_1.SetMinSize((150, 40))
        self.button_1.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_2.SetMinSize((150, 40))
        self.button_2.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_2.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_3.SetMinSize((150, 40))
        self.button_3.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_3.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_3.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_4.SetMinSize((150, 40))
        self.button_4.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_4.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_4.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_5.SetMinSize((150, 40))
        self.button_5.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_5.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_5.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_6.SetMinSize((150, 40))
        self.button_6.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_6.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_6.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_7.SetMinSize((150, 40))
        self.button_7.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_7.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_7.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_8.SetMinSize((150, 40))
        self.button_8.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_8.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_8.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_9.SetMinSize((150, 40))
        self.button_9.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_9.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_9.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_10.SetMinSize((150, 40))
        self.button_10.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_10.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_10.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_11.SetMinSize((150, 40))
        self.button_11.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_11.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_11.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        self.button_12.SetMinSize((150, 40))
        self.button_12.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.button_12.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_12.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, 1, ""))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(7, 2, 0, 0)
        grid_sizer_1.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        grid_sizer_1.Add(self.bitmap_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        grid_sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_4, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_5, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_6, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_7, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_8, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_9, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_10, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_11, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.button_12, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        self.Layout()
        # end wxGlade
       
    def onbtn1(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()
    def onbtn2(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn3(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn4(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn5(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn6(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn7(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn8(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn9(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn10(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('gksudo apt-get install openjdk-7-jre')
        event.Skip()

    def onbtn11(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()

    def onbtn12(self, event):  # wxGlade: StreamingTv.<event_handler>
        commands.getoutput('comando')
        event.Skip()       

# end of class MyFrame
if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()




Harald

ok :)
due domande:
1-  su wxglade nella sezione event del tasto non trovo modo di attivarlo, ho solo 2 caselle e qualinque cosa scrivo non rimane :boh:
2- aldila' che dal tuo codice ho capito come si fa....ho provato a eseguirlo il tasto 10 "java", mi ha chiesto giustamente la pass (sudo)ma non so se ha continuato l'installazione del java:
A- c'e modo che si veda aperto il terminale?
B- provo la cosa su qualcosa che non ho installato per verificare poi sul menu che sia stato effettivamente installato?

grazie :)
:ciao:

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Pedro

1- la prima casella dovrebbe essere apposto nella seconda una volta inserito il codice dai invio.
2 A- sarebbe meglio avviare l'applicazione con gksudo così qualsiasi tasto schiacci non richiederà la password e per l'output si può integrare il terminale vte.
B- fai pure, ma sono sicuro che l'installazione va a buon fine  ;) 


Harald

Citazione di: Pedro il Giovedì 23 Gennaio 2014, 21:35:52
1- la prima casella dovrebbe essere apposto nella seconda una volta inserito il codice dai invio.
2 A- sarebbe meglio avviare l'applicazione con gksudo così qualsiasi tasto schiacci non richiederà la password e per l'output si può integrare il terminale vte.
B- fai pure, ma sono sicuro che l'installazione va a buon fine  ;)
1- per codice intendi ad esempio "sudo apt-get install firefox firefox-locale-it"?
2-A se metto solo sudo non accade nulla, se metto gksudo mi chiede la pass e installa ,pero' non si vede che sta lavorando, si puo' integrare qualcosa che fa vedere la progressione? , cosa è il terminale vte? e come si fa?
2-B sicuro aveva la casa sull'arno nel 66  :rofl:

:ciao:

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Pedro

Studiati python e scrivi la gui tutta a mano vedrai che ti troverai meglio.

1- OnBtn1 e cosi via, lo vedi dal codice che avevo inserito
        self.Bind(wx.EVT_BUTTON, self.onbtn1, self.button_1)
        self.Bind(wx.EVT_BUTTON, self.onbtn2, self.button_2)
        self.Bind(wx.EVT_BUTTON, self.onbtn3, self.button_3)
        self.Bind(wx.EVT_BUTTON, self.onbtn4, self.button_4)
        self.Bind(wx.EVT_BUTTON, self.onbtn5, self.button_5)
        self.Bind(wx.EVT_BUTTON, self.onbtn6, self.button_6)
        self.Bind(wx.EVT_BUTTON, self.onbtn7, self.button_7)
        self.Bind(wx.EVT_BUTTON, self.onbtn8, self.button_8)
        self.Bind(wx.EVT_BUTTON, self.onbtn9, self.button_9)
        self.Bind(wx.EVT_BUTTON, self.onbtn10, self.button_10)
        self.Bind(wx.EVT_BUTTON, self.onbtn11, self.button_11)
        self.Bind(wx.EVT_BUTTON, self.onbtn12, self.button_12)


2- ovvio, con sudo l'output dove lo vedi, apposta ho messo gksudo, comunque ripeto meglio avviare la gui con gksudo in modo da non dare la password per gli altri comandi, ma poi fai come vuoi.

Con wxglade prova a vedere in giro se trovi una barra di progresso o ad integrare il terminale vte creato apposta per le gui gtk https://developer.gnome.org/vte/unstable/VteTerminal.html

sarebbe questo


il codice python vte
#!/usr/bin/env python

from gi.repository import Gtk, Vte
from gi.repository import GLib
import os

terminal     = Vte.Terminal()
terminal.fork_command_full(
    Vte.PtyFlags.DEFAULT,
    os.environ['HOME'],
    ["/bin/sh"],
    [],
    GLib.SpawnFlags.DO_NOT_REAP_CHILD,
    None,
    None,
    )

win = Gtk.Window()
win.connect('delete-event', Gtk.main_quit)
win.add(terminal)
win.show_all()

Gtk.main()


Harald

mi fai vedere il codice di quella finestra che hai fatto nell'immagine, non riesco a capire dove mettere il terminale nel mio frame :boh:
:ciao:

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Pedro

Non te la devo fare io la gui, forza impegnati che ce la farai  :)

Quella nello screenshot e fatta con gtkdialog.

#!/bin/bash

funcvspCreate() {
local f=0

while [ $f -lt $1 ]; do
echo '<vseparator height-request="'$2'"></vseparator>'
f=$((f + 1))
done
}

funchspCreate() {
local f=0

while [ $f -lt $1 ]; do
echo '<hseparator width-request="'$2'"></hseparator>'
f=$((f + 1))
done
}

export Program='
<window title="Harald" resizable="false">
<vbox>
<frame Titolo>
<hbox>
<button space-expand="true" tooltip-text="Aggiorna la lista pacchetti" height-request="40" width-request="80">
<label>UPDATE</label>
<variable>Bottone1</variable>
<action>echo "sudo apt-get update" > /tmp/update</action>
<action>refresh:term</action>
</button>
'"`funchspCreate 5`"'
<button tooltip-text="Installa Secret Maryo Chronicles" height-request="40" width-request="80">
<label>SMC</label>
<variable>Bottone2</variable>
<action>echo "sudo apt-get install smc" > /tmp/update</action>
<action>refresh:term</action>
</button>
</hbox>
'"`funcvspCreate 5`"'
<hbox>
<button space-expand="true" tooltip-text="Aggiorna sistema" height-request="40" width-request="80">
<label>UPGRADE</label>
<variable>Bottone3</variable>
<action>echo "sudo apt-get upgrade" > /tmp/update</action>
<action>refresh:term</action>
</button>
'"`funchspCreate 5`"'
<button tooltip-text="CIAO" height-request="40" width-request="80">
<label>CIAO</label>
<variable>Bottone4</variable>
<action>echo "echo ciao" > /tmp/update</action>
<action>refresh:term</action>
</button>
</hbox>
'"`funcvspCreate 5`"'
<hbox>
<button space-expand="true" tooltip-text="Pulisce il terminale" height-request="40" width-request="80">
<label>PULISCI</label>
<variable>Bottone1</variable>
<action>clear:term</action>
</button>
'"`funchspCreate 5`"'
<button tooltip-text="Secret Maryo Chronicles" height-request="40" width-request="80">
<label>SMC5</label>
<variable>Bottone2</variable>
<action>echo "echo Non ci sono limiti" > /tmp/update</action>
<action>refresh:term</action>
</button>
</hbox>
<hbox>
<terminal argv0="/bin/bash" text-foreground-color="#fff">
<variable>term</variable>
<height>10</height>
<width>30</width>
<input file>/tmp/update</input>
</terminal>
</hbox>
</frame>
<hbox>
<button cancel></button>
<button ok></button>
</hbox>
</vbox>
</window>
'

gtkdialog -p Program
sed -i 'd' /tmp/update



Harald

Citazione di: Pedro il Domenica 26 Gennaio 2014, 12:37:30
Non te la devo fare io la gui, forza impegnati che ce la farai  :)


io la gui l'ho gia fatta, quello che non riesco assolutamente a fare ( 2 gg di studio matto e disperato) e' fare apparire il terminale nella gui, perche' se aggiungo un ppa-repo xxx devo fare l'invio per la chiave....
sto diventando matto :boh:

Dell XPS17, Intel Core i7-2630QM, 6,1GB di ram, skgrafica Intel Tungsten Graphics+NVIDIA 555m(3GB), HD 500GB

Powered by EzPortal