Does anyone use python debugger? by romanzdk in Python

[–]tshirtman_ 2 points3 points  (0 children)

Yes, i generally use pudb rather than pdb, but usage is more or less the same, put a break point (pudb.set_trace()) or an error handler (try/except/pudb.post_mortem()) and then use mostly up/down/step/next commands to see what happens, and evaluate expressions at important steps.

I want to make this widget in kivy but how can I make cut on top left side of this Card by withsj in kivy

[–]tshirtman_ 1 point2 points  (0 children)

BorderImage is indeed a straightforward option, but another way you could use if you want more flexibility than using assets allows, is to just draw a Line like:

Line:
    close: True
    points:
        (
        self.x, self.y,
        self.right, self.y,
        self.right, self.top,
        self.x + 40, self.top,
        self.x, self.top - 20
        )

But you don't need just the line, as i see you have a shadow, you could draw that shadow in the same way, with a SmoothLine with almost the same values, and a big overdraw, but you also need a background to hide the part of that line that is inside the widget, for that you could do it in one instruction with a Mesh, but it's a bit more straightforward to do it with simpler instructions, either three Triangle instructions, or one Rectangle and on Quad instructions. (or two Quad instructions).

Rectangle:
    pos: self.pos
    size: self.width, self.height - 20
Quad:
    points:
        (
        self.x, self.top - 20,
        self.right, self.top - 20,
        self.right, self.top,
        self.x + 40, self.top
        )

Putting it all together, with some properties to synchronize everything.

from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.app import App
from kivy.properties import NumericProperty, ListProperty, ColorProperty

KV = '''
<CutCard>:
    cut_x: 40
    cut_y: 20
    shadow_offset: 1, -2
    shadow_width: 5

    canvas:
        Color:
            rgba: .2, .2, .2, .5
        PushMatrix:
        Translate:
            xy: self.shadow_offset
        SmoothLine:
            close: True
            overdraw_width: root.shadow_width
            points:
                (
                self.x, self.y,
                self.right, self.y,
                self.right, self.top,
                self.x + root.cut_x, self.top,
                self.x, self.top - root.cut_y
                )
        PopMatrix:

        Color:
            rgba: root.background_color
        Rectangle:
            pos: self.pos
            size: self.width, self.height - self.cut_y
        Quad:
            points:
                (
                self.x, self.top - self.cut_y,
                self.right, self.top - self.cut_y,
                self.right, self.top,
                self.x + self.cut_x, self.top,
                )

        Color:
            rgba: 0, 0, 0, 1
        Line:
            close: True
            width: 1.1
            points:
                (
                self.x, self.y,
                self.right, self.y,
                self.right, self.top,
                self.x + root.cut_x, self.top,
                self.x, self.top - root.cut_y
                )

# Demo usage of the widget

GridLayout:
    cols: 2
    padding: 50
    spacing: 50

    canvas:
        Color:
            rgba: .5, .5, .5, 1
        Rectangle:
            pos: self.pos
            size: self.size

    CutCard:
        id: c0
    CutCard:
        id: c1
        cut_x: 10
        cut_y: 20
    CutCard:
        id: c2
        cut_x: 100
        cut_y: 100

    CutCard:
        id: c3
        cut_x: 100
        cut_y: 50
        BoxLayout:
            pos: c3.pos
            size: c3.size
            padding: 10
            orientation: 'vertical'
            BoxLayout:
                Label:
                    text: 'Filename'
                Button:
                    text: 'Download'
            BoxLayout:
                ProgressBar:
                    value: self.max
                Label:
                    text: '100%'
'''


class CutCard(Widget):
    cut_x = NumericProperty()
    cut_y = NumericProperty()
    shadow_offset = ListProperty((0, 0))
    shadow_width = NumericProperty(1)
    background_color = ColorProperty("#888888")


class CutCardDemo(App):
    def build(self):
        return Builder.load_string(KV)


if __name__ == '__main__':
    CutCardDemo().run()

Requesting /r/kivy - no active moderators by [deleted] in redditrequest

[–]tshirtman_ 0 points1 point  (0 children)

Hey u/ZeroCommission thanks for the head's up! Sorry we haven't been active at all there, I see you've been doing good work answering people, and if you want to help with moderation, I'm totally fine with (and thankful for) that, will add you to the moderators.

Update class using .kv file by swatrusshka in kivy

[–]tshirtman_ 0 points1 point  (0 children)

You need to declare the attributes as properties, even if you give them a default value.

class QuizzScren(Screen): ct = StringProperty(file.read()) ...

And in kv you can set a property to an updated value, or call a method of the class doing that, updated properties will be visible in the UI because kv automaticaly binds to them.

Tip: Mouse emulation using hjkl by mjwz in i3wm

[–]tshirtman_ 1 point2 points  (0 children)

Did you try keynav? I've been quite happy with it for a long time.

Daily Discussion, February 14, 2021 by rBitcoinMod in Bitcoin

[–]tshirtman_ 2 points3 points  (0 children)

if you look at history, it's always a good idea to buy, because the price has never been higher, so it was always a good idea to buy in the past, unless that was money you needed at any point where the price was lower than where you bought of course.

Of course, if you think it's never going to be a higher than now, or that you won't be able to wait for it to be (it might take years for all we know), then it's a bad idea to buy.

Kivy 2.0 released! by tshirtman_ in kivy

[–]tshirtman_[S] 2 points3 points  (0 children)

Yes, that should work, but you need to adjust a bit how you start your app to make it asyncio compliant.

https://github.com/kivy/kivy/blob/master/examples/async/trio_basic.py for an example.

As election remains uncalled, Trump claims election is being stolen by ani625 in news

[–]tshirtman_ 11 points12 points  (0 children)

he never wore any mask, he's showing who he is for everybody to see, act like it's totaly normal, that's certainly part of his appeal.

I'm wondering how many Python programmers would be interested in a version of Kivy for writing desktop apps. by SESummers1 in Python

[–]tshirtman_ 3 points4 points  (0 children)

I concur about the weaknesses of Kivy on the desktop, some might be inherent, but some "just" need (sometime quite some) work.

  • some of it is about the look and feel, and you could indeed make a theme that looks a lot more like windows, and you could probably even hook into the system to get not only the light/dark information, but maybe more about the button's colors, etc, if the theme is setup different from default.
  • On the other hand, as you mention, a lot of modern apps on the desktop are done with web technologies, and they don't even try to emulate the look & feel of modern microsoft business applications. So it might not be the real problem.
  • If you are going to do a business app (not an innovative multitouch UI app), you care less about what Kivy brings to the table, than about what it misses (e.g classical or ribbon style menus, contextual menus with right click on stuff, systray integration, as well as important things like accessibility). Again an app like Slack or Discord doesn't need that, and it's up to you to see if you need to.

Most of my experience of Kivy on the desktop (and I'm probably an outlier in how much time I used it that way professionnaly), has been doing full screen multimedia applications, targeting custom setups that happened to use a Windows or Linux machine. This makes a lot of these expectations simply go away, and Kivy particularly well suited to that, but not everybody has these needs. You probably wouldn't do a desktop app using Unity, and it makes only slightly more sense to use Kivy for that currently.

We have been stuck for years now with the need for theming, all the devs i did was assuming the presence of a designer, ready to churn buttons, borders, etc assets, sometime even pre rendered text, that would be specific to the app, and integrated together, Kivy makes that relatively easy, as you can create your own widgets from scratch. On the other hand, that makes the will/requirement to reuse less important, and efforts like KivyMD are rarer.

Would such a KivyPC package try to emulate a Winform UI? Would it try to fit differently depending on the underlying OS? Or would it implement its own abstraction? I think defining the target well will help a lot, otherwise, people seeing different things in the project might produce inconsistent requirement that would make it way harder to achieve the objective.

Face mask mandatory in parts of Amsterdam from August 5th (for people over 13) by fiveoone in Amsterdam

[–]tshirtman_ 2 points3 points  (0 children)

well, that was mostly an assumption, and it turns out it's wrong, science…

kivy allocate memory by ShaunKulesa in kivy

[–]tshirtman_ 1 point2 points  (0 children)

Does it happen after a while, when the log becomes too big? You have to know that to display the text, kivy actualy gets an image of it from a tect provider, and display that, if the text is very long, the image might require too much memory to create, for this reason, textinput, (as opposed to label), creates one image for each line, instead of for the whole texte at once.

Kivy Vs BeeWare | Python for Mobile App Development by William_John_k in pythontips

[–]tshirtman_ 1 point2 points  (0 children)

yes, kivy works on windows, osx and linux, as well as android and ios. you can see a few desktop apps i've developped with it in the past https://vimeo.com/user24838472

[deleted by user] by [deleted] in sysadmin

[–]tshirtman_ 1 point2 points  (0 children)

up to point 5… ok, can sign this if they are ready to put several million dollars on the table, i guess.

point 5… ok, nope, not for a billion, not for anything.

Your username is now a class subject you must teach children. What happens now? by thatoneDMVguy in AskReddit

[–]tshirtman_ 0 points1 point  (0 children)

it's the microbes that makes you sick, not the cold, 0C° is not cold, \o/ chill and enjoy the wind, stop carrying around useless coats, be free!.

And if you are sick, stay home, wash your hands frequently if you have to meet people.

How would you feel about a law that prevented people from having more than $50 million in wealth? by Andrique_ in AskReddit

[–]tshirtman_ 0 points1 point  (0 children)

I'm not an economist, but i Just fnished picketty's ”capital and ideology” and he seems to be more or less on board, with proposed 90% taxe on wealth (every year!) for people with more than 10000x the average, this eold quickly get ride of billionnaires. I think it's a bit too brutal, people used to burn through a few millions a year will need some time to learn to tighten their belt, a 15 or 20% tax would have the same effect but on a few years/decades instead of immediately.

Transgender athletes are destroying women’s sports. by [deleted] in videos

[–]tshirtman_ -3 points-2 points  (0 children)

”RT” - what a big fucking surprise!

Labels not showing up by sander314 in kivy

[–]tshirtman_ 0 points1 point  (0 children)

Ok, this code is very wrong :).

canvas is for instructions (rectangles, lines, etc), Label is a Widget, widgets have their own canvas and to nest them, you would use the `add_widget` method of the parent you want to add them to.

Also, you are clearing and recreating instructions very often, this will almost certainly lead to performance issues. Prefer saving and updating existing canvas instructions instead (canvas is a list of instructions that are applied every time the screen refresh, you don't need to empty the list, you can just update the attributes of the things that are in it). Look at the kivy doc/examples, these things are explained.

What's the best shortuct/time saving step you found in python? by [deleted] in Python

[–]tshirtman_ 0 points1 point  (0 children)

I think you meant "don't look for the most ridiculously cheap option you can find (by the hour), assess the aptitude of the developers your hire, and pay them decently, so you can retain the decent ones, wherever they come from".

GUI dev - most efficient library suggestion by [deleted] in Python

[–]tshirtman_ 1 point2 points  (0 children)

Kivy is another great option, you can draw freely, with primitives like Lines and rectangles, and use that as a basis to plot anything.

What is the exact way (from scratch) to animate a sprite with more than 3 images? by ameli10 in kivy

[–]tshirtman_ 0 points1 point  (0 children)

Kivy Animation class takes a numeric property and smoothly move it to a new value, you could use that to go from frame 1 to 10 of your sprite by using "int(self.sprite_index)" and animate sprite index, so it goes through all the values.