class _(FidgetTuple): MAKE_TITLE = False MAKE_PLAINTEXT = True INNER_TEMPLATES = [ FidgetInt.template('X'), FidgetInt.template('Y'), ]
class _(FidgetTuple): MAKE_TITLE = False LAYOUT_CLS = QHBoxLayout MAKE_PLAINTEXT = True INNER_TEMPLATES = [ FidgetInt.template('X'), FidgetInt.template('Y'), ]
class PointWidget(FidgetTuple): INNER_TEMPLATES = [ FidgetInt.template('x', make_title=False), FidgetInt.template('y', make_title=False) ] MAKE_PLAINTEXT = True MAKE_TITLE = True MAKE_INDICATOR = True LAYOUT_CLS = QHBoxLayout
class NodatavalueWidgetSrc(FidgetStacked[Optional[Union[float, type(...)]]]): INNER_TEMPLATES = [ FidgetConst.template("get original value", option=("None", None)), FidgetConst.template("raster minimum (might take time)", option=("...", ...)), FidgetInt.template("given value"), ] SELECTOR_CLS = "radio" MAKE_TITLE = True MAKE_INDICATOR = False MAKE_PLAINTEXT = False LAYOUT_CLS = QHBoxLayout
class NodatavalueWidgetDst(FidgetStacked[Optional[Union[float, type(...)]]]): INNER_TEMPLATES = [ FidgetConst.template("don't change", option=("None", None)), FidgetConst.template("change to default value (for DTM)", option=("...", ...)), FidgetInt.template("change to a set value"), ] SELECTOR_CLS = "radio" MAKE_TITLE = True MAKE_INDICATOR = False MAKE_PLAINTEXT = False LAYOUT_CLS = QHBoxLayout
class MyTable(FidgetTable): MAKE_TITLE = True MAKE_PLAINTEXT = True MAKE_INDICATOR = True INNER_TEMPLATES = [ FidgetInt.template('X'), FidgetCheckBox.template('pos'), ] ROWS = 1, 1, None SCROLLABLE = False
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) b = 0 num_dialog = FidgetQuestion(FidgetInt('b', make_plaintext=True), parent=self, cancel_value=None) layout = QVBoxLayout() line_edit = FidgetInt('a') layout.addWidget(line_edit) label = QLabel('0') layout.addWidget(label) browse_btn = QPushButton('...') layout.addWidget(browse_btn) @browse_btn.clicked.connect def _(click_event): nonlocal b value = num_dialog.exec() if value.is_ok() and value.value is not None: b = value.value label.setText(str(b)) show_btn = QPushButton('show') layout.addWidget(show_btn) @show_btn.clicked.connect def _(ce): a = line_edit.value() if not a.is_ok(): print(a) return print(a.value * b) self.setLayout(layout)
from fidget.backend.QtWidgets import QApplication, QHBoxLayout, QFrame from fidget.widgets import FidgetLabel, FidgetInt, FidgetStacked if __name__ == '__main__': app = QApplication([]) w = FidgetStacked('number', [ FidgetLabel('auto', initial=('auto', 123456)), FidgetInt('raw text'), ], make_plaintext=True, frame_style=QFrame.Box, selector_cls=FidgetStacked.CheckBoxSelector, layout_cls=QHBoxLayout, make_indicator=False) w.show() res = app.exec_() print(w.value()) exit(res)
class GdalosWidget(FidgetTabs): INNER_TEMPLATES = [ FidgetDict.template( "basic", [ ( "filename", raster_fidget.template("source file", exist_cond=True), ), ( "cog", FidgetCheckBox.template( "make cog (cloud optimized geotiff)", initial_value=True), ), FidgetCheckBox.template("prefer_2_step_cog", initial_value=False), FidgetCheckBox.template("delete_temp_files", initial_value=True), FidgetCheckBox.template("overwrite", initial_value=False), ( "multi_file_as_vrt", FidgetCheckBox.template("treat multi file as vrt", initial_value=False), ), FidgetCheckBox.template("sparse_ok", initial_value=True), FidgetCheckBox.template("write_info", initial_value=True), FidgetCheckBox.template("write_spec", initial_value=True), ], make_plaintext=False, ), FidgetDict.template( "overviews", [ ( "ovr_idx", FidgetOptional.template( FidgetInt.template("source overview index", placeholder=False), make_title=True, ), ), FidgetOptional.template( FidgetInt.template("dst_ovr_count", placeholder=False), make_title=True, ), FidgetCombo.template( "ovr_type", options=list( chain((("AUTO", ...), ("None", None)), OvrType.__members__)), initial_index=0, make_title=True, ), FidgetCheckBox.template("keep_src_ovr_suffixes", initial_value=True), ], make_plaintext=False, ), FidgetDict.template( "format", [ # todo validate drivers? ( "of", FidgetCombo.template( "output format", options=list( chain((("AUTO", ...), ), GdalOutputFormat.__members__)), initial_index=0, make_title=True, ), ), ( "outext", FidgetEditCombo.template("output extension", options=("tif", ), make_title=True), ), FidgetCheckBox.template("tiled", options=("NO", "YES")), FidgetCombo.template( "big_tiff", options=["YES", "NO", "IF_NEEDED", "IF_SAFER"], initial_value="IF_SAFER", make_title=True, ), ], make_plaintext=False, ), FidgetDict.template( "conversion", [ FidgetCombo.template( "lossy", options=[("AUTO", None), False, True], initial_index=0, make_title=True, ), FidgetCombo.template( "kind", options=list( chain((("AUTO", ...), ), RasterKind.__members__.items())), initial_index=0, make_title=True, ), FidgetCheckBox.template("expand_rgb", initial_value=False), FidgetMinimal.template( FidgetOptional.template( CrsWidget.template( "warp_srs", make_plaintext=True, make_indicator=True, frame_style=QFrame.Box | QFrame.Plain, )), make_title=True, make_plaintext=False, make_indicator=False, initial_value=None, ), ( "out_res", FidgetOptional.template( FidgetTuple.template( "resolution", inner_templates=( FidgetInt.template("X", make_indicator=False, make_title=False), FidgetInt.template("Y", make_indicator=False, make_title=False), ), layout_cls=QHBoxLayout, ), make_indicator=False, make_title=True, make_plaintext=True, ), ), ], make_plaintext=False, ), FidgetDict.template( "extent", [ FidgetOptional.template( FidgetConverter.template( FidgetTuple.template( "extent", inner_templates=[ FidgetFloat.template(letter) for letter in "WESN" ], layout_cls=QHBoxLayout, make_title=False, ), converter_func=lambda x: GeoRectangle.from_lrdu(*x ), back_converter_func=GeoRectangle.lrdu.fget, ), make_title=True, make_indicator=False, make_plaintext=True, ), ( "extent_in_4326", FidgetCheckBox.template( "extent is in EPSG:4326 (WGS84Geo), otherwise it should be in target srs", initial_value=True), ), ( "srcwin", FidgetOptional.template( FidgetConverter.template( FidgetTuple.template( "source window", inner_templates=[ FidgetFloat.template(letter) for letter in "XYWH" ], layout_cls=QHBoxLayout, make_title=False, ), converter_func=lambda x: GeoRectangle(*x), back_converter_func=GeoRectangle.xywh.fget, ), make_title=True, make_indicator=False, make_plaintext=True, ), ), FidgetOptional.template( FidgetInt.template("partition", placeholder=False), make_title=True, ), ], make_plaintext=False, ), FidgetDict.template( 'NoData value', [ FidgetCheckBox.template("hide nodatavalue", initial_value=False), ( "dst_nodatavalue", NodatavalueWidgetDst.template("dst_nodatavalue"), ), ( "src_nodatavalue", NodatavalueWidgetSrc.template("src_nodatavalue"), ), ], make_plaintext=False, ), FidgetDict.template( "output", [ ( "out_path", FidgetOptional.template( raster_fidget.template("output path: folder", exist_cond=None), make_indicator=False, ), ), ( "out_path_with_src_folders", FidgetCheckBox.template( "output path: keep source folder structure", initial_value=True, ), ), ( "out_filename", FidgetOptional.template( raster_fidget.template( "output path: set destination file", exist_cond=None), make_indicator=False, ), ), ], make_plaintext=False, ), FidgetDict.template( "advanced", [ FidgetCombo.template( "resampling_alg", options=list( chain((("None", None), ("AUTO", ...)), GdalResamplingAlg.__members__)), initial_index=0, make_title=True, ), FidgetCheckBox.template("keep_alpha"), FidgetSpin.template( "quality", 1, 100, initial_value=75, make_title=True), ], make_plaintext=False, ), ]