1

I'm a new here, and a new to Python. In Python, how to move an align-self to left or right? According to my codes below, how to move Atomic Number to upper on the left-hand side and Atomic Weight to lower on the left-hand side? Here are the codes.

class Element(Button):
    def __init__(self, info, **kwargs):
        super(Element, self).__init__(**kwargs)
        self.info = info
        self.background_color = ELEMENT_COLOR_MAP[info["Element_Category"]]
        self.text = "[size=17]{}\n[/size][size=32][b]{}[/b][/size][size=17]\n{}[/size][size=17]\n{}[/size]".format(
            info['Atomic_Number'], info['Symbol'], info['Name'], info['Atomic_Weight'])
        self.text_size = self.size
        self.halign = 'center'
        self.valign = 'middle'
        self.markup = True

I've tried to change it many times, but it doesn't work anymore. Please suggest me or fix it for me. Thank you!

I tried to fix the code by changing self.halign = 'left', but everything moved to the left side. I only want to move the Atomic Number (to the upper left-hand side) and Atomic Weight (to the lower left-hand side), while keeping the Symbol and Name in the middle positions.

3
  • 3
    This seems to be related to some GUI library. Add an appropriate tag and/or mention it in the question. Commented Apr 14, 2023 at 19:50
  • did you try setStyleshett() method?? Commented Apr 14, 2023 at 19:55
  • I didn't try it. Thanks for your response. Commented Apr 15, 2023 at 19:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.