2 Replies - 401 Views - Last Post: 12 July 2019 - 08:34 AM Rate Topic: -----

#1 Lavacorn430   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 19

Kivy and Python. trying to make a word generator and upload picture

Posted 11 July 2019 - 05:52 PM

I am trying to make a character randomizer app and I am using kivy and python. I am wondering how I would upload a picture to be the background and how I would go about coding a box for words to generate into.

import kivy
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.app import App
from kivy.uix.label import Label
import random
from random import randint
# def do():


# string = ['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard']

# abi = (random.choice(string))

# return abi

# allignment first then race then class then bg



str1 = ['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock',
        'Wizard']

clas = str1

str2 = ['Acolyte', 'Charlatan', 'Criminal', 'Entertainer', 'Folk Hero', 'Gladiator', 'Guild Artisan', 'Guild Merchant',
        'Hermit', 'Knight', 'Noble', 'Outlander', 'Pirate', 'Sage', 'Sailor', 'Soldier', 'Spy', 'Urchin']

background = str2

str3 = ['Chaotic Evil', 'Chaotic Good', 'Chaotic Neutral', 'Lawful Evil', 'Lawful Good', 'Lawful Neutral',
        'Neutral Evil', 'Neutral Good',
        'True Neutral']

alligm = str3

str4 = ['Aarakokra', 'Aasimar', 'Air Genasi', 'Bugbear', 'Deep Gnome', 'Dragonborn', 'Drow', 'Dwarf', 'Earth Genasi',
        'Fire Genasi', 'Firbolg', 'Forest Gnome', 'Githyanki', 'Githzerai', 'Goblin', 'Half-elf', 'Halfling',
        'Half-orc', 'High Elf', 'Hobgoblin', 'Human', 'Kenku', 'Kobold', 'Lizardfolk', 'Orc', 'Rock Gnome', 'Tabaxi',
        'Tiefling', 'Triton', 'Warforged', 'Water Genasi', 'Wood Elf', 'Yuan-ti']

race = str4

# dice(roll 4 number 6 dice and drop the lowest value)
# sort the numbers form highest to lowest and add top 3
# gonna need 6 of these



def rollstats():
    statslist = []
    for h in range(6):
        h = h
        total = []
        for a in range(4):
            a = a
            numm = randint(1, 6)
            total.append(numm)
        total.remove(min(total))
        totalnum = 0
        for x in total:
            totalnum += x
        statslist.append(totalnum)
    return statslist


#


nowstats = rollstats()





# ASSIGNING STATS




print(nowstats)

class MyApp(App):
    def build(self):
        return Label(text="Let The Dice Roll")

class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)

        self.inside = GridLayout()
        self.inside.cols = 2

        # the cols are tricky
        self.cols =


        self.inside.add_widget(Label(print(random.choice(alligm)))
        self.allignm = print(random.choice(alligm))
        self.inside.add_widget(self.name)

        self.submit = Button(text="Stats Will Roll", font_size=40)
        self.swr.bind(on_press=self.pressed)
        self.add_widget(self.submit)

    def pressed(self, instance):
        allignment = self.allgnm.text
        clas = self.clas.text
        race = self.race.text

        print("Allignment", allignm, "clas", clas, "race", race)
        self.allignm.text = ""
        self.clas.text = ""
        self.race.text = ""




if __name__ == "__main__":
     MyApp().run()

This post has been edited by DK3250: 12 July 2019 - 03:51 AM
Reason for edit:: Code tags added


Is This A Good Question/Topic? 0
  • +

Replies To: Kivy and Python. trying to make a word generator and upload picture

#2 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 559
  • View blog
  • Posts: 1,749
  • Joined: 27-December 13

Re: Kivy and Python. trying to make a word generator and upload picture

Posted 12 July 2019 - 03:57 AM

Hello Lavacorn430, welcome to Dream.In.Code, I hope you will find it helpful.

When uploading code, please remember to use code tags; once in the input field you'll find a code icon just above the text field. I have added the tags in your post #1.

I'm not too familiar with kivy, so for now I'll leave your question to others...

However, what idea do you have yourself? What did you try? And what problem did you see?
Was This Post Helpful? 0
  • +
  • -

#3 Lavacorn430   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 19

Re: Kivy and Python. trying to make a word generator and upload picture

Posted 12 July 2019 - 08:34 AM

View PostDK3250, on 12 July 2019 - 03:57 AM, said:

However, what idea do you have yourself? What did you try? And what problem did you see?


I've been watching tutorials and I tried making the input boxes into a word generating box but I can't seem to figure out how to do that.
I've tried to put a picture in using kivy but it isn't working so I'm still looking for a tutorial on how to do that on just regular python code
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1