Skip to content

Commit

Permalink
Merge pull request #44 from noelpower/SLE15-SP2-example-fixes
Browse files Browse the repository at this point in the history
Sle15 sp2 example fixes
  • Loading branch information
dmulder committed Feb 23, 2023
2 parents ffb87ad + f27223f commit 74bbfc9
Show file tree
Hide file tree
Showing 31 changed files with 216 additions and 178 deletions.
3 changes: 2 additions & 1 deletion examples/BarGraph3.py
Expand Up @@ -96,12 +96,13 @@ def main(self):
else:
new_values = ycpbuiltins.add(
new_values,
old_val + (-(sign) * (inc / (len(values) - 1) ))
old_val + (-(sign) * (inc // (len(values) - 1) ))
)

i2 = i2 + 1

values = copy.deepcopy(new_values)

UI.ChangeWidget(Id("bar"), "Values", values)

if button_id == "close" or "button_id" == "cancel":
Expand Down
2 changes: 1 addition & 1 deletion examples/ComboBox2.py
Expand Up @@ -56,7 +56,7 @@ def main(self):
UI.OpenDialog(
VBox(
Label("You will get a pizza with:"),
Label("toppings"),
Label(toppings),
PushButton("&OK")
)
)
Expand Down
6 changes: 3 additions & 3 deletions examples/DefaultButtons1.py
Expand Up @@ -47,11 +47,11 @@ def main(self):
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Id("back"),
Symbol("back"),
"&Back",
Id("abort"),
Symbol("abort"),
"Ab&ort",
Id("next"),
Symbol("next"),
"&Next"
)
)
Expand Down
6 changes: 3 additions & 3 deletions examples/DefaultButtons2.py
Expand Up @@ -46,11 +46,11 @@ def main(self):
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Id("back"),
Symbol("back"),
"&Back",
Id("abort"),
Symbol("abort"),
"Ab&ort",
Id("next"),
Symbol("next"),
"&Next"
)
)
Expand Down
6 changes: 3 additions & 3 deletions examples/DefaultButtons3.py
Expand Up @@ -46,11 +46,11 @@ def main(self):
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Id("back"),
Symbol("back"),
"&Back",
Id("abort"),
Symbol("abort"),
"Ab&ort",
Id("next"),
Symbol("next"),
"&Next"
)
)
Expand Down
28 changes: 28 additions & 0 deletions examples/HSquash1.py
@@ -0,0 +1,28 @@
# encoding: utf-8

from yast import import_module
import_module('UI')
from yast import *
class HSquash1Client:
def main(self):
UI.OpenDialog(
Opt("defaultsize"),
VBox(
VCenter(
HSquash(
VBox(
Left(CheckBox("short")),
Left(CheckBox("longer")),
Left(CheckBox("even longer")),
Left(CheckBox("yet even longer")),
)
) # Makes the VBox nonstretchable horizontally
), # Makes the HSquash stretchable vertically
Left(PushButton("bottom left"))
)
)
UI.UserInput()
UI.CloseDialog()

HSquash1Client().main()

9 changes: 1 addition & 8 deletions examples/Image1.py
Expand Up @@ -11,20 +11,13 @@ def main(self):
VBox(
Image(
Id("image"),
"/usr/share/YaST2/theme/current/wallpapers/welcome.jpg",
"/usr/share/grub2/themes/openSUSE/logo.png",
"fallback text"
),
PushButton(Opt("default"), "&OK")
)
)
UI.UserInput()
if UI.WidgetExists(Id("image")):
UI.ChangeWidget(Id("image"), "Enabled", False)
UI.UserInput()
UI.ChangeWidget(Id("image"), "Enabled", True)
UI.UserInput()
else:
ycpbuiltins.y2error("No such widget id")
UI.CloseDialog()


Expand Down
4 changes: 2 additions & 2 deletions examples/Label1_cs.py
Expand Up @@ -7,8 +7,8 @@ class Label1CsClient:
def main(self):
UI.OpenDialog(
VBox(
Label("\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7"),
PushButton("&OK\u011B\u0161")
Label(u"\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7"),
PushButton(u"&OK\u011B\u0161")
)
)
UI.UserInput()
Expand Down
4 changes: 2 additions & 2 deletions examples/Label1_de.py
Expand Up @@ -8,9 +8,9 @@ def main(self):
UI.OpenDialog(
VBox(
Label(
"\u00DF\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00DC\u00DC\u00DC\u00DC\u00DC\u00F6\u00DF\u00DF\u00DF\u00DF\u00E4\u00C4\u00C4\u00C4\u00C4"
u"\u00DF\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00DC\u00DC\u00DC\u00DC\u00DC\u00F6\u00DF\u00DF\u00DF\u00DF\u00E4\u00C4\u00C4\u00C4\u00C4"
),
PushButton("\u00C4&\u00D6\u00E4")
PushButton(u"\u00C4&\u00D6\u00E4")
)
)
UI.UserInput()
Expand Down
2 changes: 1 addition & 1 deletion examples/Label1_ja.py
Expand Up @@ -5,7 +5,7 @@
from yast import *
class Label1JaClient:
def main(self):
UI.OpenDialog(VBox(Label("\u5B8C\u6642"), PushButton("&OK\u5B8C\u6642")))
UI.OpenDialog(VBox(Label(u"\u5B8C\u6642"), PushButton(u"&OK\u5B8C\u6642")))
UI.UserInput()
UI.CloseDialog()

Expand Down
4 changes: 2 additions & 2 deletions examples/Label2_ml.py
Expand Up @@ -8,8 +8,8 @@ def main(self):
UI.OpenDialog(
VBox(
Label(
"\u00DF\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00DC\u00DC\u00DC\u00DC\u00DC\u00F6\u00DF\u00DF\u00DF\u00DF\u00E4\u00C4\u00C4\u00C4\u00C4\n" +
"\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7\n" +
u"\u00DF\u00F6\u00F6\u00F6\u00F6\u00F6\u00F6\u00DC\u00DC\u00DC\u00DC\u00DC\u00F6\u00DF\u00DF\u00DF\u00DF\u00E4\u00C4\u00C4\u00C4\u00C4\n" +
u"\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7\n" +
"multiple lines."
),
PushButton("&OK")
Expand Down
6 changes: 3 additions & 3 deletions examples/MultiProgressMeter2.py
Expand Up @@ -110,10 +110,10 @@ def main(self):

if widgetClass == "RadioButton":
currentUnitID = UI.QueryWidget("unit", "CurrentButton")
print "type %s"%type(currentUnitID)
print ("type %s"%type(currentUnitID))
#if Ops.is_term?(currentUnitID):
if isinstance (currentUnitID, YCPTerm):
unit = currentUnitID.value(0)
if isinstance (currentUnitID, tuple):
unit = currentUnitID[0]

ycpbuiltins.y2milestone("New unit: 2^%1", unit)
UI.ReplaceWidget(
Expand Down
2 changes: 1 addition & 1 deletion examples/MultiSelectionBox3.py
Expand Up @@ -26,7 +26,7 @@ def main(self):
PushButton(Opt("default"), "&OK")
)
)
UI.ChangeWidget("toppings", "SelectedItems", ["sausage", "onions"])
UI.ChangeWidget("toppings", "SelectedItems", [Symbol("sausage"), Symbol("onions")])

UI.UserInput()
selected_items = UI.QueryWidget(Id("toppings"), "SelectedItems")
Expand Down
3 changes: 1 addition & 2 deletions examples/PatternSelector-wizard-with-packages.py
Expand Up @@ -22,8 +22,7 @@ def main(self):

UI.OpenDialog(
Opt("defaultsize"),
#Wizard("back", "", "cancel", "&Cancel", "ok", "&OK")
Wizard(Opt("stepsEnabled"), Id("back"), "", Id("cancel"), "&Cancel", Id("ok"), "&OK")
Wizard(Symbol("back"), "", Symbol("cancel"), "&Cancel", Symbol("ok"), "&OK")
)


Expand Down
2 changes: 1 addition & 1 deletion examples/RichText1_cs.py
Expand Up @@ -12,7 +12,7 @@ def main(self):
RichText(
"<h3>RichText example</h3>" +
"<p>This is a <i>RichText</i> widget.</p>" +
"<p>It's czech: \u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7<i>HTML</i>, or german \u00F6\u00F6\u00E4\u00E4\u00E4</p>" +
u"<p>It's czech: \u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7<i>HTML</i>, or german \u00F6\u00F6\u00E4\u00E4\u00E4</p>" +
"<p><b>bold</b> and <i>italic</i> you can rely on.</p>" + "<p>" +
"<font color=blue>colored\t</font>" +
"<font color=red>\ttext \t</font>" +
Expand Down
12 changes: 6 additions & 6 deletions examples/SetLanguage.py
Expand Up @@ -52,12 +52,12 @@ def main(self):
Heading("Test Dialog"),
Label(
"Fonts may have changed\n" +
"Gr\u00FC\u00DF Gott\n" +
"Czech (\u010Desky)\n" +
"Greek (\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC)\n" +
"Russian (\u0420\u0443\u0441\u0441\u043A\u0438\u0439)\n" +
"\u6F22\u5B57\u304B\u306A\u76F4\n" +
"Hangul (\uD55C\uAE00)"
u"Gr\u00FC\u00DF Gott\n" +
u"Czech (\u010Desky)\n" +
u"Greek (\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC)\n" +
u"Russian (\u0420\u0443\u0441\u0441\u043A\u0438\u0439)\n" +
u"\u6F22\u5B57\u304B\u306A\u76F4\n" +
u"Hangul (\uD55C\uAE00)"
),
PushButton(Opt("default"), "&OK")
)
Expand Down
4 changes: 2 additions & 2 deletions examples/ShortcutConflict5.py
Expand Up @@ -14,7 +14,7 @@ class ShortcutConflict5Client:
def main(self):
UI.OpenDialog(
Opt("defaultsize"),
Wizard("back", "&Back", "abort", "&Abort", "next", "&Next")
Wizard(Symbol("back"), "&Back", Symbol("abort"), "&Abort", Symbol("next"), "&Next")
)

fields = HBox(
Expand All @@ -40,7 +40,7 @@ def main(self):

ycpbuiltins.y2milestone("Got event: %1", event)

if Ops.get(event, "ID") == "abort":
if "ID" in event and event["ID"] == "abort":
break

UI.CloseDialog()
Expand Down
2 changes: 1 addition & 1 deletion examples/ShortcutConflict6.py
Expand Up @@ -10,7 +10,7 @@ def main(self):

UI.OpenDialog(
HBox(
PushButton("&\u00A7\u00A7"),
PushButton(u"&\u00A7\u00A7"),
PushButton("&???"),
PushButton("?&??"),
PushButton("&!!!"),
Expand Down
10 changes: 5 additions & 5 deletions examples/SlideShowDemo.py
Expand Up @@ -63,11 +63,11 @@ def main(self):
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Id("back"),
Symbol("back"),
"&Back",
Id("abort"),
Symbol("abort"),
"Ab&ort",
Id("next"),
Symbol("next"),
"&Next"
)
)
Expand Down Expand Up @@ -303,8 +303,8 @@ def twoDigits(self,n):
return ycpbuiltins.sformat("0%1", n) if (n < 10) else ycpbuiltins.sformat("%1", n)

def formatTime(self, seconds):
hours = (seconds / 3600)
minutes = (seconds / 60)
hours = (seconds // 3600)
minutes = (seconds // 60)
seconds = (seconds % 60)
return ycpbuiltins.sformat(
"%1:%2:%3",
Expand Down
10 changes: 5 additions & 5 deletions examples/SlideShowDemo2.py
Expand Up @@ -63,11 +63,11 @@ def main(self):
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Id("back"),
Symbol("back"),
"&Back",
Id("abort"),
Symbol("abort"),
"Ab&ort",
Id("next"),
Symbol("next"),
"&Next"
)
)
Expand Down Expand Up @@ -290,8 +290,8 @@ def twoDigits(self,n):
return ycpbuiltins.sformat("0%1", n) if (n < 10) else ycpbuiltins.sformat("%1", n)

def formatTime(self, seconds):
hours = (seconds / 3600)
minutes = (seconds / 60)
hours = (seconds // 3600)
minutes = (seconds // 60)
seconds = (seconds % 60)
return ycpbuiltins.sformat(
"%1:%2:%3",
Expand Down
9 changes: 5 additions & 4 deletions examples/Table-icons.py
Expand Up @@ -43,9 +43,9 @@ def main(self):

test = Term("icon", "22x22/apps/" + "iconName")
test = Term("cell",test)
print "working %s"%test.toString()
print ("working %s"%test.toString())
test = Term("cell", Term("icon", "22x22/apps/" + "iconName"))
print "not working %s"%test.toString()
print ("not working %s"%test.toString())


for iconName in ycpbuiltins.foreach(iconList):
Expand Down Expand Up @@ -76,7 +76,8 @@ def main(self):
# Read a directory with icons.
#
def readIconDir(dir):
iconList = list(SCR.Read(Path(".target.dir"), dir))
iconList = SCR.Read(Path(".target.dir"), dir)
iconList = list(iconList) if iconList else []
ycpbuiltins.y2debug("Dir %1: %2 entries", dir, ycpbuiltins.size(iconList))
# #TODO #FIXME add ycbbuiltins.filter()
# #TODO #FIXME add ycbbuiltins.sort()
Expand All @@ -90,7 +91,7 @@ def readIconDir(dir):


filtered.sort()
print "returning %d items"%len(filtered)
print ("returning %d items"%len(filtered))
return copy.deepcopy(filtered)

TableIconsClient().main()
Expand Down
20 changes: 10 additions & 10 deletions examples/Table1_utf8.py
Expand Up @@ -7,28 +7,28 @@ class Table1Utf8Client:
def main(self):
UI.OpenDialog(
VBox(
Label("\u00D6\u00DFemsflk\u00C4\u00C4"),
Label(u"\u00D6\u00DFemsflk\u00C4\u00C4"),
MinSize(
25,
7,
Table(
Header(
"\u00C4nerhe\u00DF",
"\u00C4\u00DF\u00F6\u00F6\u00E4\u00E4\u00E4\u00E4\u00E4"
u"\u00C4nerhe\u00DF",
u"\u00C4\u00DF\u00F6\u00F6\u00E4\u00E4\u00E4\u00E4\u00E4"
),
[
Item(
Id('1'),
"\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7",
u"\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7",
6
),
Item(Id(2), "\u011B\u0161\u0159\u017E", None),
Item(Id(3), "\u00C4nder\u00DF\u00DF\u00DF", 8),
Item(Id(4), "\u5B8C\u6642", 12),
Item(Id(2), u"\u011B\u0161\u0159\u017E", None),
Item(Id(3), u"\u00C4nder\u00DF\u00DF\u00DF", 8),
Item(Id(4), u"\u5B8C\u6642", 12),
Item(Id(5), "Zoo", 25),
Item(Id(6), "\u017D\u010D\u0159", 6),
Item(Id(7), "\u00E1\u0161\u0159", 8),
Item(Id(8), "\u00C1lklsd", 7),
Item(Id(6), u"\u017D\u010D\u0159", 6),
Item(Id(7), u"\u00E1\u0161\u0159", 8),
Item(Id(8), u"\u00C1lklsd", 7),
Item(Id(9), "Alphaphet", 15),
Item(Id(10), "an", 1)
]
Expand Down

0 comments on commit 74bbfc9

Please sign in to comment.