33
44from PyQt5 .QtCore import QPointF , Qt
55from PyQt5 .QtGui import QIcon
6- from PyQt5 .QtWidgets import QBoxLayout , QButtonGroup , QWidget , QSizePolicy
6+ from PyQt5 .QtWidgets import QBoxLayout , QButtonGroup , QSizePolicy , QWidget
77
88from siui .components import SiDenseHContainer , SiDenseVContainer , SiTitledWidgetGroup
99from siui .components .button import (
10+ SiCapsuleButton ,
11+ SiCheckBoxRefactor ,
1012 SiFlatButton ,
1113 SiFlatButtonWithIndicator ,
1214 SiLongPressButtonRefactor ,
1618 SiRadioButtonWithAvatar ,
1719 SiRadioButtonWithDescription ,
1820 SiSwitchRefactor ,
19- SiToggleButtonRefactor , SiCheckBoxRefactor , SiCapsuleButton ,
21+ SiToggleButtonRefactor ,
2022)
2123from siui .components .chart import SiTrendChart
24+ from siui .components .combobox_ import SiCapsuleComboBox
2225from siui .components .container import SiDenseContainer , SiTriSectionPanelCard , SiTriSectionRowCard
23- from siui .components .editbox import SiLabeledLineEdit , SiDoubleSpinBox , SiCapsuleLineEdit , SiSpinBox
26+ from siui .components .editbox import SiCapsuleLineEdit , SiDoubleSpinBox , SiLabeledLineEdit , SiSpinBox
2427from siui .components .label import SiLinearIndicator , SiLinearPartitionIndicator
2528from siui .components .page import SiPage
2629from siui .components .progress_bar_ import SiProgressBarRefactor
@@ -47,6 +50,7 @@ def createDenseContainer(parent: SiDenseContainer,
4750 side : Qt .Edges = Qt .LeftEdge | Qt .TopEdge ) -> SiDenseContainer :
4851 container = SiDenseContainer (parent )
4952 container .layout ().setDirection (direction )
53+ container .layout ().setSpacing (12 )
5054 container .setSizePolicy (QSizePolicy .Preferred , QSizePolicy .Preferred )
5155 try :
5256 yield container
@@ -71,6 +75,23 @@ def __init__(self, *args, **kwargs):
7175 with self .titled_widgets_group as group :
7276 group .addTitle ("按钮" )
7377
78+ with createPanelCard (group , "下拉选择器" ) as card :
79+ with createDenseContainer (card .body (), QBoxLayout .LeftToRight ) as container :
80+ combo_editable = SiCapsuleComboBox (self )
81+ combo_editable .setTitle ("可编辑选择器" )
82+ combo_editable .setMinimumHeight (36 )
83+ combo_editable .setEditable (True )
84+ combo_editable .addItems (["Python" , "C++" , "JavaScript" ])
85+
86+ combo_not_editable = SiCapsuleComboBox (self )
87+ combo_not_editable .setTitle ("只读选择器" )
88+ combo_not_editable .setMinimumHeight (36 )
89+ combo_not_editable .setEditable (False )
90+ combo_not_editable .addItems (["Python" , "C++" , "JavaScript" ])
91+
92+ container .addWidget (combo_editable )
93+ container .addWidget (combo_not_editable )
94+
7495 with createPanelCard (group , "胶囊按钮" ) as card :
7596 with createDenseContainer (card .body (), QBoxLayout .LeftToRight ) as container :
7697 capsule_button_1 = SiCapsuleButton (self )
@@ -572,30 +593,31 @@ def test_func_2():
572593
573594 self .linear_edit_box = SiCapsuleLineEdit (self )
574595 self .linear_edit_box .resize (560 , 36 )
596+ self .linear_edit_box .setTitleWidthMode (SiCapsuleLineEdit .TitleWidthMode .Ratio )
575597 self .linear_edit_box .setTitle ("Repository Name" )
576598 self .linear_edit_box .setText ("PyQt-SiliconUI" )
577599
578600 self .linear_edit_box2 = SiCapsuleLineEdit (self )
579601 self .linear_edit_box2 .resize (560 , 36 )
602+ self .linear_edit_box2 .setTitleWidthMode (SiCapsuleLineEdit .TitleWidthMode .Ratio )
580603 self .linear_edit_box2 .setTitle ("Owner" )
581604 self .linear_edit_box2 .setText ("ChinaIceF" )
582605
583606 self .linear_edit_box3 = SiCapsuleLineEdit (self )
584607 self .linear_edit_box3 .resize (560 , 36 )
608+ self .linear_edit_box3 .setTitleWidthMode (SiCapsuleLineEdit .TitleWidthMode .Ratio )
585609 self .linear_edit_box3 .setTitle ("Description" )
586610 self .linear_edit_box3 .setText ("A powerful and artistic UI library based on PyQt5" )
587611
588- self .check_button = SiPushButtonRefactor (self )
612+ self .check_button = SiFlatButton (self )
589613 self .check_button .setText ("确定" )
590- self .check_button .clicked .connect (self .linear_edit_box .validate )
591- self .check_button .clicked .connect (self .linear_edit_box2 .validate )
592- self .check_button .clicked .connect (self .linear_edit_box3 .validate )
614+ self .linear_edit_box3 .addWidgetToRight (self .check_button )
593615
594616 self .editbox .body ().setSpacing (11 )
595617 self .editbox .body ().addWidget (self .linear_edit_box )
596618 self .editbox .body ().addWidget (self .linear_edit_box2 )
597619 self .editbox .body ().addWidget (self .linear_edit_box3 )
598- self .editbox .body ().addWidget (self .check_button )
620+ # self.editbox.body().addWidget(self.check_button)
599621 self .editbox .body ().addPlaceholder (12 )
600622 self .editbox .adjustSize ()
601623
0 commit comments