Python - Combox y texbox - Python

 
Vista:
sin imagen de perfil
Val: 18
Ha disminuido su posición en 5 puestos en Python (en relación al último mes)
Gráfica de Python

Combox y texbox - Python

Publicado por James Andres (6 intervenciones) el 16/10/2020 19:38:44
Cordial Saludo.

Tengo la siguiente interfaz y deseo que la informacion que seleciono en el combox al dar click me aparezca en la caja de texto.

Este es el codigo que tengo de la interfaz realizada.

muchas gracias en lo que me puedan colaborar.,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# importing libraries
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from datetime import date
from datetime import datetime
 
 
  #Día actual
today = date.today()
 
#Fecha actual
now = datetime.now()
 
print(today)
print(now)
 
new_date="El día actual es {}".format(today.month)
 
 
print(new_date)
class Window(QMainWindow):
 
 
 
 
 
    def __init__(self):
        super().__init__()
 
         # setting title
        self.setWindowTitle("Python ")
 
 
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
 
 
        # calling method
        self.UiComponents()
 
        # showing all the widgets
        self.show()
 
        # method for widgets
    def UiComponents(self):
 
        # creating a combo box widget
        boxcd = QComboBox(self)
 
        boxcd.setGeometry(  90,  35, 50, 30)
 
        boxm = QComboBox(self)
 
        boxm.setGeometry( 180,  35, 90, 30)
 
        boxd = QComboBox(self)
 
        boxd.setGeometry(  270,  35, 50, 30)
 
        boxano = QComboBox(self)
 
        boxano.setGeometry(  360,  35, 80, 30)
 
        boxen = QComboBox(self)
 
        boxen.setGeometry(  450,  35, 50, 30)
 
 
        # geek list
        list_cd = [" ", "C01", "C02", "C03","C04", "C05", "C06", "C07", "C08", "C09","C10", "C11", "C12","C13", "C14", "C15", "C16","C17", "C18", "C19"
                       ,"C20", "C21", "C22","C23", "C24", "C25", "C26","C27", "C28"   ]
 
        list_m = [" ", "ENERO", "FEBRERO", "MARZO","ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SEPTIEMBRE","OCTUBRE", "NOVIEMBRE", "DICIEMBRE" ]
 
        list_d = [" ", "01", "02", "03","04", "05", "06", "07", "08", "09","10", "11", "12","13", "14", "15", "16","17", "18", "19"
                       ,"20", "21", "22","23", "24", "25", "26","27", "28"   ]
 
        list_ano = [" ", "2020", "2021", "2022","2023", "2024"]
 
        list_en = [" ", "E1", "E2", "E3","E4", "E5"]
 
 
 
        # adding list of items to combo box
        boxcd.addItems(list_cd)
        boxm.addItems(list_m)
        boxd.addItems(list_d)
        boxano.addItems(list_ano)
        boxen.addItems(list_en)
 
         # creating push button
        button = QPushButton("Click !", self)
         #                  I/D   up   wid
        button.setGeometry(  230,  350, 150, 30)
 
 
 
        # creating texbox
        line = QLineEdit(self)
        line.setGeometry(  230,  100, 190, 30)
 
 
 
 
 
    def action(self):
 
        # showing the pop up
        self.combo_box.showPopup()
 
 
 
# create pyqt5 app
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())

Captura
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Combox y texbox - Python

Publicado por yoyyo (1 intervención) el 16/10/2020 21:10:00
hola:
es muy simple, pero para hacerlo modifique la declaración de algunos objetos, como el combobox y el qlineedit, que dicho sea de paso, te conviene usar self hasta que aprendas bien cuando no usarlo, por estar no está mal y por no estar puede no funcionar.:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#-*- coding: utf - 8 -*-
 
# importing libraries
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from datetime import date
from datetime import datetime
 
#Día actual
today = date.today()
 
#Fecha actual
now = datetime.now()
 
print(today)
print(now)
 
new_date="El día actual es {}".format(today.month)
 
print(new_date)
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        # setting title
        self.setWindowTitle("Python ")
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
        # calling method
        self.UiComponents()
        # showing all the widgets
        self.show()
 
# method for widgets
    def UiComponents(self):
        # creating a combo box widget
        self.boxcd = QComboBox(self)
        self.boxcd.setGeometry( 90, 35, 50, 30)
        boxm = QComboBox(self)
        boxm.setGeometry( 180, 35, 90, 30)
        boxd = QComboBox(self)
        boxd.setGeometry( 270, 35, 50, 30)
        boxano = QComboBox(self)
        boxano.setGeometry( 360, 35, 80, 30)
        boxen = QComboBox(self)
        boxen.setGeometry( 450, 35, 50, 30)
        # geek list
        list_cd = [" ", "C01", "C02", "C03","C04", "C05", "C06", "C07", "C08", "C09","C10", "C11", "C12","C13", "C14", "C15", "C16","C17", "C18", "C19"
        ,"C20", "C21", "C22","C23", "C24", "C25", "C26","C27", "C28" ]
        list_m = [" ", "ENERO", "FEBRERO", "MARZO","ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SEPTIEMBRE","OCTUBRE", "NOVIEMBRE", "DICIEMBRE" ]
        list_d = [" ", "01", "02", "03","04", "05", "06", "07", "08", "09","10", "11", "12","13", "14", "15", "16","17", "18", "19"
        ,"20", "21", "22","23", "24", "25", "26","27", "28" ]
        list_ano = [" ", "2020", "2021", "2022","2023", "2024"]
        list_en = [" ", "E1", "E2", "E3","E4", "E5"]
        # adding list of items to combo box
        self.boxcd.addItems(list_cd)
        boxm.addItems(list_m)
        boxd.addItems(list_d)
        boxano.addItems(list_ano)
        boxen.addItems(list_en)
 
        # creating push button
        self.button = QPushButton("Click !", self)
        self.button.clicked.connect(self.tomar_item)
        # I/D up wid
        self.button.setGeometry( 230, 350, 150, 30)
        # creating texbox
        self.line = QLineEdit(self)
        self.line.setGeometry( 230, 100, 190, 30)
 
    def action(self):
        # showing the pop up
        self.combo_box.showPopup()
 
    def tomar_item(self):
        self.item = self.boxcd.currentText()
        self.line.setText(self.item)
 
# create pyqt5 app
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 18
Ha disminuido su posición en 5 puestos en Python (en relación al último mes)
Gráfica de Python

Combox y texbox - Python

Publicado por James Andres (6 intervenciones) el 16/10/2020 23:42:28
Muchas gracias por sus amable colaboracion.
cualquier cosita estare por aca nuavemente. mil gracias.!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar