teleren/devto huggingface dataset:
Desktop Window, Button & Click with Python
Tags: python, pyqt
Published: 2019-07-07 13:45:30

---
title: Desktop Window, Button & Click with Python
published: true
description: python
tags: python, pyqt
cover_image: https://thepracticaldev.s3.amazonaws.com/i/32sez7xafysrnf3mia0i.jpg
---
Python apps don't need be command line only. You can create desktop software. In programmer language: graphical  user interfaces (GUI)

So how do you make that? You need to use a module. There are several modules like tkinter, wxwidgets and pyqt. PyQt is a good choice.

If you know the object orientated programming concepts this is pretty easy. If not, check out the resources below.

So let's make a desktop application, but for the modern desktop

<img src="https://media.giphy.com/media/iKHUw8sPI9ZZMpDQbW/giphy.gif">

### Example

The program below creates a desktop window with a button. If you click the button a popup will show (QMessageBox). Inside the class we set some window properties.

    #!/usr/bin/python3
    from PyQt5 import QtCore
    from PyQt5.QtWidgets import *
    
    class MainWindow(QMainWindow):
        def __init__(self, name, title):
            super(MainWindow, self).__init__()
            self.w = 0
            self.h = 0
            self.init_ui(name, title)
    
        def init_ui(self, name, title):
            self.w = 200
            self.h = 100
            self.setObjectName(name)
            self.setWindowTitle(title) 
            self.resize(self.w, self.h) 
    
            self.btn_clickme = QPushButton(self)
            self.btn_clickme.setGeometry(QtCore.QRect(10, 10, 100, 24))
            self.btn_clickme.setObjectName('click_me')
            self.btn_clickme.setText('clicky click！')
            self.btn_clickme.clicked.connect(self.do_something)
    
        def do_something(self):
            QMessageBox.information(self, 'clicked', 'clicked！')
        
    if __name__ == '__main__':
        import sys
        app = QApplication(sys.argv)
        n = 'Hello'
        t = 'Hello, Soaring!'
        ex = MainWindow(n, t)
        ex.show()
        sys.exit(app.exec_())

Results in:

![](https://thepracticaldev.s3.amazonaws.com/i/hfsjkbicdce2z1cqscc2.png)

Resources:

* <a href="https://pythonprogramminglanguage.com/pyqt-tutorials">Basic PyQt tutorial</a>
* <a href="https://gumroad.com/l/pysqtsamples">Complete PyQT course & many examples</a>
* <a href="https://pythonbasics.org">Python tutorial</a>
Key takeaways from GraphQL Conference @Berlin, Germany
Tags: graphql, womenintech, webdev, techtalks
Published: 2019-07-07 13:31:41

This article has been originally posted on my Medium account [here](https://medium.com/@rinx.goyal/key-takeaways-from-graphql-conference-berlin-germany-40ead85a9c2)

#Day 1
Below are my takeaways from Day 1 of the GraphQL conference which took place in Berlin/Germany. Amazing talks by fantastic speakers!!

#Dan Schafer’s talk — GraphQL before GraphQL
Everything has to be coded to be async — even when you think it’s not needed to be async, still make it async.
Resolvers have to be async
2. GraphQL was never meant to solve for Authorization, Caching of results, below, rate Limiting when it was developed

3. Resolvers should be thin and should only map to business logic and not contain actual business logic

#Sashko Stubailo explained how easy it is to build custom GraphQL tooling for specific use-cases
1. Write tests with less boilerplate code and ability to write custom overrides for testing edge cases, error states using this graphql-tools. Read more [here](https://www.freecodecamp.org/news/a-new-approach-to-mocking-graphql-data-1ef49de3d491/).
2. Preventing a breaking change by checking if a GraphQL field is being referenced or not. Read about it [here](https://gist.github.com/stubailo/7a2071c4e568a185726c583073695bc0)

#Sasha Solomon talked about the errors array in GraphQL response and how to deal with them in a better manner.
1. All errors end up in the errors array, but not all errors are the same. 
2. Some of them are real errors like server not available, bad gateway but others like might just be ‘alternative results’ like a blocked user, suspended user, etc.

3. To differentiate errors like above, use union types and basis the type in response, the client can decide what to do.
union UserResult = User| IsBlocked | Suspended

The key thing is not to create too many types and keep it only to important ones.
This talk was easy to grasp and implement at the get-go :)

#Best Practices around migrating to GraphQL
1. Think about making incremental changes, edge cases and ability to safely rollback
2. Build adaptors for easy migration
Automated test suites are super important to do this herculean task

#Marc-André Giroux’s talk about distributing schemas in GraphQL
1. Always ask the question if distributing schemas is really necessary?
2. Schema stitching helps us achieve schema distribution but business logic often leaks into the API gateway and it ends up being more complex than just simple “proxying”
Ideally an API gateway should be like below:
- Decouple” the clients from the “services” involved in the use cases
- Avoid domain logic
- Schemas should be easy to import in the gateway
Talk slides [here](https://speakerdeck.com/xuorig/so-you-want-to-distribute-your-graphql-schema-16fd4e47-eae7-4437-be2a-5e9b803a675e?slide=44).

This was my attempt to write down what was captured in my notebook and brain :D 
I will be writing another blog post about learning from Day 2. Stay tuned!
Progressive Web App Template - GitHub
Tags: web, webdev, progressiveweapp, pwa
Published: 2019-07-07 13:24:07

## Build your [first-pwa](https://pwabuzz.web.app/)

Learn how to build your first progressive web app with [pwafire.org](https://pwafire.org) in [this starter codelab](
https://pwafire.org/developer/codelabs/pwafire/)

 - In this codelab, you'll be able to build a progressive web app with mostly static resources or meant to work best for static web apps or sites.

## Using [Workbox](https://developers.google.com/web/tools/workbox/) instead 
We will be adding a more advanced codelab to help you learn how to build Progressive Web Apps that are dynamic or for large scale production scenario by having the power to :

  - choose what to cache

  - dictate how to cache

  - decide how long to cache

  - decide when to cache

  - decide what resources to cache

  - decide how much of a resource to cache 

## Demo in play...

Whoaaa 🎉 we gatchu! You'll be able to finally create a progressive web app that [looks like me here](https://pwabuzz.web.app/)
Turtle Shapes with Python
Tags: python, beginners, kids
Published: 2019-07-07 13:07:42

---
title: Turtle Shapes with Python
published: true
description: python, beginners
tags: python, beginners, kids
---
The turtle module lets you draw all kinds of things. It's originally made for kids, but it's fun :)

This program below draw a bunch of shapes on the window including a circle, square and triangle.

### Python Turtle shapes

If you run the program you see the turtle drawing the shapes. The turtle starts walking and leaves behind a trail. Over time you see the shapes show up.

    #!/usr/bin/python3
    import turtle
    import random    
    
    def drawshape(sides, length):
        angle = 360.0 / sides
        for sides in range(sides):
            turtle.forward(length)
            turtle.right(angle)
    
    def moveTurtle(x, y):
        turtle.penup()
        turtle.goto(x,y)
        turtle.pendown()
    
    def drawsquare(length):
        drawshape(4,length)
    
    def drawtriangle(length):
        drawshape(3,length)
    
    def drawcircle(length):
        drawshape(360, length)
    
    drawcircle(1)
    drawsquare(100)
    drawtriangle(250)

    turtle.done()

Result:

![](https://thepracticaldev.s3.amazonaws.com/i/pg7ae8819kfeqgx9ion1.png)

Learn Python:
* https://pythonprogramminglanguage.com
* https://pythonprogramminglanguage.com/pyqt5-hello-world/
* https://pythonbasics.org
Python & Turtle. Drawing in the jungle
Tags: python, turtle
Published: 2019-07-07 12:52:46

---
title: Python & Turtle. Drawing in the jungle
published: true
description: python, turtle
tags: python, turtle
cover_image: https://thepracticaldev.s3.amazonaws.com/i/p3cm5vickutkehjygvza.jpg
---
Learn Python doesn't have to be boring. You may be stuck in the command line trying all kinds of codes. Why not have some fun learning?

The module turtle lets you draw in the Python programming language.
Officially it's is a popular way for introducing programming to kids, but even for adults its fun :) 

### Turtle example

Turtle draws on the screen. It can move coordinate and change colors. In the example below the olympic games logo is drawn

    #!/usr/bin/python3
    # https://pythonprogramminglanguage.com
    import turtle
    import time
    
    turtle.setworldcoordinates(-250, -250, 640, 480)
    turtle.width(20)
    
    turtle.circle(60)
    turtle.penup()
    turtle.forward(140)
    turtle.pendown()
    turtle.color("red")
    turtle.circle(60)
    turtle.penup()
    turtle.forward(140)
    turtle.pendown()
    turtle.color("yellow")
    turtle.circle(60)
    turtle.penup()
    turtle.goto(210, -50)  
    turtle.pendown()
    turtle.color("blue")
    turtle.circle(60)
    turtle.penup()
    turtle.goto(60, -50)
    turtle.pendown()
    turtle.color("green")
    turtle.circle(60)

    time.sleep(5)

Outputs:

![](https://thepracticaldev.s3.amazonaws.com/i/y3oj9hvjmpnikqvddnw4.png)


Python resources:

* https://pythonprogramminglanguage.com
* https://pythonprogramminglanguage.com/pyqt5-hello-world/
* https://pythonbasics.org
* https://python.org
How does Dev.to give rich link image previews of articles with no cover images?
Tags: help, discuss
Published: 2019-07-07 12:41:18

![richlinkpreview](https://thepracticaldev.s3.amazonaws.com/i/dfbyidqwzixzd2zszfgp.png)
This is an article whose author did not provide a cover image but Dev.to is able to generate an image with the title. The image acts as a placeholder in `rich link previews`

My question is how can I do that.
GUI input with Python
Tags: python
Published: 2019-07-07 12:34:41

---
title: GUI input with Python
published: true
description: python
tags: python
---
EasyGUI,  an easy-to-use interface for simple GUI interaction, can grab user input easily.  It's based on tkinter and you can make quick user interactions with it.

Never heard of EasyGUI? See also: https://dev.to/petercour/easygui-with-python-example-45h5

So you can grab user input quickly with only a few lines of code.

Take a look at this:

    #!/usr/bin/python3
    import easygui as g

    def enterbox(msg,title):
        msg = g.enterbox(msg, title, default='',strip = False,image=None)
        print(msg)

    enterbox(msg = 'content',title = 'title')

Then:

![](https://thepracticaldev.s3.amazonaws.com/i/silpxl6nzpvkuq09qti8.png)

want to ask a number?

    #!/usr/bin/python3
    import easygui as g
    
    def integerbox(msg,title,minNum,maxNum):
        msg = g.integerbox(msg, title,default=0, lowerbound=minNum, upperbound=maxNum, image=None)
        print(msg)

    integerbox('content', 'title',0,99)


Then:

![](https://thepracticaldev.s3.amazonaws.com/i/cemkyjaqxds39ax6do3x.png)


Resources:

* <a href="https://gumroad.com/l/ErLc">Python Tkinter Video Course</a>
* <a href="https://pythonbasics.org/tkinter/">Tkinter stuff</a>
* <a href="https://pythonbasics.org/">Python tutorial</a>
Practicing PDD - Panic Driven Development
Tags: tdd, coding, software, development
Published: 2019-07-07 12:34:35

---
title: Practicing PDD - Panic Driven Development
published: true
description: Panic, write code, repeat
tags: TDD, coding, software, development
---

After the initial wave of success of agile development techniques, one particular technique has survived and emerged throughout the years: PDD Panic Driven Development. 
This technique shares the core concepts of agile development methodologies but removes all the ceremonies and process burden that reduces velocity in teams.
Let's see more in detail what are the principles of this methodology.

## Recent issues have priority
Whenever a new issue comes up in the middle of the sprint, it takes priority over any planned work. New is always better and has higher priority. As a matter of fact it should be one of the principles of the agile development as well. 
The focus on delivering value to customer requires the team to take care of new items and postpone previously defined work.

## Write enough code to fix the issue
Developers write code for a living. Bugs can be fixed only by code. Design and UX discussion can only slow down the development. Code a solution first, verify your assumptions with the fix.
If the fix works, you solved the issue.

## Tests should be a follow-up task
Once the fix is implemented, tests can be planned as a task to be done in the future. Tests are useful but not a priority. You can take care of them later. File a ticket and put it in the backlog.
Manual testing should enough to prove your fix.

## Trust your instinct
Programming is art. Art has an intrinsic instinctive component. Trust your gut. Code your solution. Deploy it. Only the bold succeeds.

## Process is flexible
Any process put in place to develop, test and release software is just a set of conventions and rules that are not written in stone. Critical fixes require different approaches. It is expected that you bend the process in order to act faster.

## It’s a manager driven process
As part of one team, managers are entitled to give their opinions on development matters. 
Refactoring or good practices can and should be overruled by business needs. Engineers can express their opinions but they should eventually commit to any need that comes from above. 


### Conclusion
*PDD* is a technique that can give great performance improvements in a short period time for every project. 
It is practiced by several companies around the world. It represents the core of agile and extreme programming.
EasyGUI with Python, example
Tags: python
Published: 2019-07-07 12:25:22

---
title: EasyGUI with Python, example
published: true
description: python
tags: python
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xppylvgta3aabbfxwhvm.png
---

EasyGui provides an easy-to-use interface for simple GUI interaction
with a user. 

It does not require the programmer to know anything about
tkinter, frames, widgets, callbacks or lambda. 

All GUI interactions are invoked by simple function calls that return results.

Example

    #!/usr/bin/python3         
    # https://pythonbasics.org                                                                                                                                                
    import easygui as g
    import sys

    def ccbox():
        if g.ccbox('Do you agree?','Survey',choices=('Yes','No')):
            g.msgbox('Hockey')
        else:
            sys.exit(0)
    
    ccbox()

Creates this output:

![](https://thepracticaldev.s3.amazonaws.com/i/xppylvgta3aabbfxwhvm.png)

This needs tkinter installed (on ubuntu),

    sudo apt-get install python3-tk

Because its uses tkinter to make its gui.

easygui can create different types of popups:

    #!/usr/bin/python3         

    import easygui as g
    def msgbox(msg,title):
        g.msgbox(msg, title, ok_button='ok',image=None)

    msgbox(msg = 'content',title = 'title')

![](https://thepracticaldev.s3.amazonaws.com/i/7766a9u3zr69mqjv6qfw.png)

### choice

Lets you choose between options

    #!/usr/bin/python3         

    import easygui as g

    def buttonbox(msg,title):
        g.buttonbox(msg, title, choices=('button1','button2','button3'),image=None)
    
    buttonbox(msg = 'content',title = 'title')

Then

![](https://thepracticaldev.s3.amazonaws.com/i/lekq90qynrvo14ovtlod.png)


Resources:

* <a href="https://gumroad.com/l/ErLc">Python Tkinter Video Course</a>
* <a href="https://pythonbasics.org/tkinter/">Tkinter stuff</a>
* <a href="https://pythonbasics.org/">Python tutorial</a>
CST026 — Pull Requests und Code Review
Tags: podcast, german, productivity, git
Published: 2019-07-07 12:07:53

![](https://thepracticaldev.s3.amazonaws.com/i/a7dbt0jd8fzq4reqdbcg.jpg)

<a href="https://open.spotify.com/show/1q3dDiYvXHcMaDFopGt3Mh" rel="Listen on Spotify">![](https://thepracticaldev.s3.amazonaws.com/i/vq1ok1pwsnvvgbk2krye.png)</a>

Mac'n'Cheese ist so ziemlich das Beste, was Nudeln und — dem meisten — Käse passieren kann. Gibt es eigentlich ein Restaurant, indem man erst die Rohzutaten eines fertigen Gerichts essen muss, bevor man ordentlich bekocht wird und das Endergebnis anhimmeln und wertschätzen kann? Ich sehe hier eine Marktlücke! 

Wie dem auch sei: Wir reden in dieser Folge über Pull Requests, Code Reviews und Code Reviews und Pull Requests. Wie arbeiten wir in unseren jeweiligen Teams damit? Was sind die Vorteile und würden wir jemals wieder ohne? Spoiler: Wahrscheinlich nicht. Max bereitet sich mit dem <a rel="noopener noreferrer" target="_blank" href="https://www.samueladams.com/our-beers/rebel-ipa-family/ipa/rebel-ipa">Samual Adams Rebel IPA</a> auf die bevorstehende Red Wedding vor, während Nathan mit der <a rel="noopener noreferrer" target="_blank" href="https://www.duden.de/rechtschreibung/Stino">stino</a> <a rel="noopener noreferrer" target="_blank" href="https://www.bionade.de/zitrone-bergamotte/">Bi(er)onade Zitrone-Bergamotte</a> lieber auf Nummer sicher geht.

Max kann ausserdem erzählen, dass <a rel="noopener noreferrer" target="_blank" href="https://store.pantone.com/de/de/color-of-the-year-2019">„Living Coral”</a> die Farbe des Jahres 2019 ist und Nathan hat ein Video von einem Adler gesehen, <a href="https://www.langweiledich.net/flug-ueber-die-alpen-aus-der-sicht-eines-adlers/ " rel="noopener noreferrer" target="_blank">der über die Alpen gleitet</a>. Weitere erwähnte Links aus dieser Folge sind:

<ul>
<li><a rel="noopener noreferrer" target="_blank" href="https://git-scm.com/book/en/v2">Pro Git, ein Buch über git — git-scm.com</a>
<li><a rel="noopener noreferrer" target="_blank" href="https://www.heise.de/developer/artikel/Nachgebessert-Pull-Request-Workflows-in-der-Praxis-4341944.html?seite=all">Pull Request Workflows in der Praxis — heise.de</a>
<li><a rel="noopener noreferrer" target="_blank" href="https://dev.to/kulkarniankita9/the-art-of-humanizing-pull-requests-prs-2238">The Art of Humanizing Pull Requests — dev.to</a>
</ul>

Wir bedanken uns wie immer für's Zuhören. Verbesserungsvorschläge, Getränkeempfehlungen, Liebesbekundungen und Kritik bitte wie immer via Twitter an <a href="https://twitter.com/codestammtisch" rel="noopener noreferrer" target="_blank">@codestammtisch</a> oder diskret per Mail an <a href="mailto:hallo@codestammtis.ch">hallo-at-codestammtis.ch</a>

Kurze Werbeeinblendung zum Schluss: <a href="https://steadyhq.com/de/codestammtisch" rel="payment">Unterstütze den Codestammtisch auf Steady</a>. Vielen Dank!

Hier gehts zur Folge: https://codestammtis.ch/2019/04/22/cst026-pull-requests-und-code-review/
Angular 9|8 Custom Validation Tutorial with Examples
Tags: angular98, angular, angular98customvalidation
Published: 2020-01-31 19:50:56

---
title: Angular 9|8 Custom Validation Tutorial with Examples
published: true
tags: Angular 9|8, Angular ,Angular 9|8 Custom Validation, 
canonical_url: https://www.positronx.io/angular-8-custom-validation-tutorial-with-examples/
---

The post [Angular 8 Custom Validation Tutorial with Examples](https://www.positronx.io/angular-8-custom-validation-tutorial-with-examples/) appeared first on [positronX.io](https://www.positronx.io).

In this Angular 8 tutorial, we will look at how to **create custom validators using Angular 8 Reactive Forms**. Angular is a robust front-end framework; it comes with powerful built-in validators like minLength, maxLength, pattern, and required. Sometimes we have to deal with more difficult validation cases in real-world scenario thats where the custom validators help us to deal with the situation.

Implementing custom validators using Angular 8 Reactive Forms is very easy. Custom validators are just like functions which we often use in our day to day programming tasks. You can create custom validators for any given scenario.


[Click here to read more](https://www.positronx.io/angular-8-custom-validation-tutorial-with-examples/)
what is the difference between looping the div and making it as separate component and looping?
Tags: react
Published: 2019-07-07 11:58:25

Hi this is my first post in this community , seeking for a clarification.I'll attach the stackover flow link which I have posted and didn't get the proper clarification, kindly check the link and  post your explanation 

https://stackoverflow.com/questions/56872154/what-is-the-difference-between-looping-the-div-and-making-it-as-separate-compone
CST031 — Testabdeckung
Tags: podcast, german, testing
Published: 2019-07-07 11:36:22

![](https://thepracticaldev.s3.amazonaws.com/i/ecshvbvrgt5tt0s6sk4g.jpg)

<a href="https://open.spotify.com/show/1q3dDiYvXHcMaDFopGt3Mh" rel="Listen on Spotify">![](https://thepracticaldev.s3.amazonaws.com/i/vq1ok1pwsnvvgbk2krye.png)</a>

Max hat letztens ein neues Projekt angefangen, bei dem er alles richtig und alles besser machen möchte. Dazu gehört auch, dass er mit dem Team testgetrieben entwickelt und dazu gehört für ihn auch eine hohe <a href="https://de.wikipedia.org/wiki/Testabdeckung" rel="noopener noreferrer" target="_blank">Testabdeckung</a>.

Doch was ist das überhaupt? Und warum muss die hoch sein? Was bringt das für Vorteile und wie überzeuge ich auch andere davon? Und wie zur Hölle nochmal erreiche ich eigentlich eine hohe Testabdeckung, wenn ich nicht — wie Max — auf der grünen Wiese stehe, sondern mit „historisch gewachsenem“ Code arbeite?

Das diskutieren Max bei einem leichten <a href="https://www.ganter.com/produkte/ganter-spezialitaeten/ganter-badisch-hell.html" rel="noopener noreferrer" target="_blank">Ganter Badisch Hell</a> und Nathan bei einem schweren <a href="https://www.riedenburger.de/startseite/biere/plankstettener-biere/plankstettener-maibock/article/maibock-fest-im-kloster-plankstetten.html" rel="noopener noreferrer" target="_blank">Plankstettener Maibock</a> — und Discounter-Schokopudding-Resten! Und Cat Content.

Wir bedanken uns wie immer für's Zuhören. Verbesserungsvorschläge, Getränkeempfehlungen, Liebesbekundungen und Kritik bitte wie immer via Twitter an <a href="https://twitter.com/codestammtisch" rel="noopener noreferrer" target="_blank">@codestammtisch</a> oder diskret per Mail an <a href="mailto:hallo@codestammtis.ch">hallo-at-codestammtis.ch</a>

Kurze Werbeeinblendung zum Schluss: <a href="https://steadyhq.com/de/codestammtisch" rel="payment">Unterstütze den Codestammtisch auf Steady</a>. Vielen Dank!

Hier gehts zur Folge: https://codestammtis.ch/2019/07/01/cst031-testabdeckung/