[Python] sharp develop: problema con esempio codice python

Riccardo mancuso mancuso.riccardo63 a gmail.com
Ven 4 Ott 2013 19:56:28 CEST


ciao a tutti,
mi sto cimentando con sharpdevelop, nello sviluppare una interfaccia
grafica stupida: 2 textbox che prendono due numeri ("a" e "b") e quando
faccio click su un pulsante, faccio la somma e la visualizzo su un terzo
textbox ("c") .

Il codice è il seguente:

import System.Drawing
import System.Windows.Forms

from System.Drawing import *
from System.Windows.Forms import *

class MainForm(Form):
    def __init__(self):
        self.InitializeComponent()

    def InitializeComponent(self):
        self._button1 = System.Windows.Forms.Button()
        self._a = System.Windows.Forms.TextBox()
        self._label1 = System.Windows.Forms.Label()
        self._label2 = System.Windows.Forms.Label()
        self._b = System.Windows.Forms.TextBox()
        self._label3 = System.Windows.Forms.Label()
        self._c = System.Windows.Forms.TextBox()
        self._label4 = System.Windows.Forms.Label()
        self._label5 = System.Windows.Forms.Label()
        self.SuspendLayout()
        #
        # button1
        #
        self._button1.Location = System.Drawing.Point(349, 113)
        self._button1.Name = "button1"
        self._button1.Size = System.Drawing.Size(75, 23)
        self._button1.TabIndex = 0
        self._button1.Text = "Somma"
        self._button1.UseVisualStyleBackColor = True
        self._button1.Click += self.Button1Click
        #
        # a
        #
        self._a.Location = System.Drawing.Point(219, 35)
        self._a.Name = "a"
        self._a.Size = System.Drawing.Size(100, 20)
        self._a.TabIndex = 1
        #
        # label1
        #
        self._label1.Location = System.Drawing.Point(163, 35)
        self._label1.Name = "label1"
        self._label1.Size = System.Drawing.Size(31, 23)
        self._label1.TabIndex = 2
        self._label1.Text = "a"
        self._label1.Click += self.Label1Click
        #
        # label2
        #
        self._label2.Location = System.Drawing.Point(163, 74)
        self._label2.Name = "label2"
        self._label2.Size = System.Drawing.Size(31, 23)
        self._label2.TabIndex = 4
        self._label2.Text = "b"
        self._label2.Click += self.Label2Click
        #
        # b
        #
        self._b.Location = System.Drawing.Point(219, 74)
        self._b.Name = "b"
        self._b.Size = System.Drawing.Size(100, 20)
        self._b.TabIndex = 3
        #
        # label3
        #
        self._label3.Location = System.Drawing.Point(163, 113)
        self._label3.Name = "label3"
        self._label3.Size = System.Drawing.Size(31, 23)
        self._label3.TabIndex = 6
        self._label3.Text = "Tot"
        #
        # c
        #
        self._c.Location = System.Drawing.Point(219, 113)
        self._c.Name = "c"
        self._c.Size = System.Drawing.Size(100, 20)
        self._c.TabIndex = 5
        #
        # label4
        #
        self._label4.Location = System.Drawing.Point(349, 38)
        self._label4.Name = "label4"
        self._label4.Size = System.Drawing.Size(31, 23)
        self._label4.TabIndex = 7
        self._label4.Text = "+"
        #
        # label5
        #
        self._label5.Location = System.Drawing.Point(349, 71)
        self._label5.Name = "label5"
        self._label5.Size = System.Drawing.Size(31, 23)
        self._label5.TabIndex = 8
        self._label5.Text = "="
        #
        # MainForm
        #
        self.ClientSize = System.Drawing.Size(781, 258)
        self.Controls.Add(self._label5)
        self.Controls.Add(self._label4)
        self.Controls.Add(self._label3)
        self.Controls.Add(self._c)
        self.Controls.Add(self._label2)
        self.Controls.Add(self._b)
        self.Controls.Add(self._label1)
        self.Controls.Add(self._a)
        self.Controls.Add(self._button1)
        self.Name = "MainForm"
        self.Text = "prova"
        self.Load += self.MainFormLoad
        self.ResumeLayout(False)
        self.PerformLayout()


    def MainFormLoad(self, sender, e):
        pass

    def Button1Click(self, sender, e):
        pass

    def Label1Click(self, sender, e):
        pass

    def Label2Click(self, sender, e):
        pass




L'interfaccia grafica è quindi disegnata.
Come faccio a fare l'operazione ?
Ossia come punto ai valori di "a" e "b" e scrivo il risultato in "c",
quando clicco sul pulsante ?
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20131004/a5d3ad0d/attachment.html>


Maggiori informazioni sulla lista Python